summaryrefslogtreecommitdiffstats
path: root/lib/music_methods/musicProvider.dart
blob: 0e4d450b0ebdd1e2758c23a5682561884116c68f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: Apache-2.0
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:musicplayer/class.dart';
import 'package:musicplayer/music_methods/modeClass.dart';

final PositionProvider = StateNotifierProvider<Position,Duration>(((ref) => Position()));

class Position extends StateNotifier<Duration>{
    Position() : super(Duration(seconds: 0));
    void update(value) async{
        state = value;
    }


}

final CurrentSongProvider = StateNotifierProvider<Current, CurrentSong>(((ref) => Current()));

class Current extends StateNotifier<CurrentSong>{
    Current() : super(currentval);
    static final CurrentSong currentval = CurrentSong(title: 'title', artist: 'unknown', duration: '0min 0sec',isPlaying: false, time: '0');

    void update({ String? title,  String? artist,  String? duration,  bool? isPlaying, String? time}){
        state = state.copyWith(title: title, artist: artist, duration: duration, isPlaying: isPlaying,time: time);
    }

}

final VolumeProvider = StateNotifierProvider<Volume,int>(((ref) => Volume()));

class Volume extends StateNotifier<int>{
    Volume() : super(70);
    
    void update(int val){
        state = val;
    }

}

final Modeprovider = StateNotifierProvider<mode,Mode>(((ref) => mode()));

class mode extends StateNotifier<Mode>{
    mode() : super(intial_value);
    static final Mode intial_value = Mode(isRepeat: true, isSingle : false, prev: true);
    
    void update({bool? isSingle, bool? isRepeat, bool? prev}){
        state = state.copyWith(isRepeat : isRepeat, isSingle : isSingle,prev: prev);
    }

}

final currIndexProvider = StateNotifierProvider<Index,int>(((ref) => Index()));

class Index extends StateNotifier<int>{
    Index() : super(0);
    
    void update(int val){
        state = val;
    }

}