import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fitness/fitness.dart';
class StepNotifier extends StateNotifier<int?> {
StepNotifier() : super(0);
void _readSteps() async {
final now = DateTime.now();
final steps = await Fitness.read(
timeRange: TimeRange(start: now.subtract(const Duration(days: 1)), end: now),
bucketByTime: 1,
timeUnit: TimeUnit.days,
);
state = steps; //Here is a error as cannot assign list(array) to type int ?
}
}
final stepProvider = StateNotifierProvider((ref) => StepNotifier());
Basically Here I am writing a State to show steps taken to user with riverpod and using StateNotifierProvider but i cant assign steps to state variable as steps is a list which is a array in another progrramming language and the initial value of state is integer which is shown on Super(0)