summaryrefslogtreecommitdiffstats
path: root/lib/provider.dart
blob: 463e7437da990ecd6672ef68d42425a08806000d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 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;
  }
}