diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ffc80763..bbdcdf4a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ + _stepCountStream; + + @override + RxInt step = 0.obs; + + RxInt get steps => step; + + @override + void getCurrentStep(StepCount event){ + step.value = event.steps; + } + + void onStepCountError(error) { + //print('onStepCountError: $error'); + step.value = 0; + } + + void initPlatformState() { + _stepCountStream = Pedometer.stepCountStream; + _stepCountStream.listen(getCurrentStep).onError(onStepCountError); + } + + @override + List getWeeklySteps(startDate, endDate){ + List a = []; + return a; + } + +} \ No newline at end of file diff --git a/lib/utils/walking_service.dart b/lib/utils/walking_service.dart index 282e9bd1..e0e4e8b1 100644 --- a/lib/utils/walking_service.dart +++ b/lib/utils/walking_service.dart @@ -1,7 +1,10 @@ +import 'package:get/get.dart'; +import 'package:pedometer/pedometer.dart'; + abstract class WalkingService { - late int step; + late RxInt step; - int getCurrentStep(); + void getCurrentStep(StepCount event); List getWeeklySteps(startDate, endDate); } diff --git a/pubspec.lock b/pubspec.lock index 7152019e..da49c419 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -171,6 +171,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + pedometer: + dependency: "direct main" + description: + name: pedometer + sha256: e8c574dae778276fa848873c6ea2015a636a91e8572a4a652b04a4fcd6c54259 + url: "https://pub.dev" + source: hosted + version: "4.0.1" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index bfec167b..fbe81a88 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: dio: ^5.4.3+1 get: ^4.6.6 flutter_dotenv: ^5.1.0 + pedometer: ^4.0.1 dev_dependencies: flutter_test: