31 lines
805 B
Dart
31 lines
805 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:your_app/services/motion_service.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// アプリの起動時にモーション更新を開始
|
|
await MotionService.startMotionUpdates();
|
|
|
|
runApp(MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
// ... アプリの設定
|
|
);
|
|
}
|
|
}
|
|
|
|
// アプリケーションの状態が変わったときにモーション更新を停止/再開する
|
|
@override
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
if (state == AppLifecycleState.paused) {
|
|
MotionService.stopMotionUpdates();
|
|
} else if (state == AppLifecycleState.resumed) {
|
|
MotionService.startMotionUpdates();
|
|
}
|
|
}
|