summaryrefslogtreecommitdiffstats
path: root/lib/provider.dart
blob: 4c9ed0a2d07d3c9a63b8f8c962b90b5a81508a19 (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
// SPDX-License-Identifier: Apache-2.0

import 'dart:async';
import 'dart:math';

import 'package:flutter_riverpod/flutter_riverpod.dart';

final fuelProvider = StateNotifierProvider<fuel,double>((ref) =>
    fuel(),
);

class fuel extends StateNotifier<double>{
  late Timer timer;
  fuel() : super(0.2){

    Timer.periodic(Duration(seconds: 5), (timer) {
      double num = Random().nextInt(100).toDouble();
      update(num);
    });
  }
  void update(value){
    state = value;
  }
}

final DateTimeProvider = StateNotifierProvider<datetime,DateTime>((ref) =>
    datetime(),
);

class datetime extends StateNotifier<DateTime>{
  datetime() : super(DateTime.now()){

    Timer.periodic(Duration(seconds: 30), (timer) {
      DateTime _now = DateTime.now();
      update(_now);
    });
  }
  void update(value){
    state = value;
  }
}