20240903 pre release

This commit is contained in:
2024-09-03 22:17:09 +09:00
parent fe46d46ab6
commit 2c0bb06e74
44 changed files with 610 additions and 154 deletions

View File

@ -0,0 +1,30 @@
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();
}
}

View File

@ -0,0 +1,21 @@
import 'package:flutter/services.dart';
class MotionService {
static const MethodChannel _channel = MethodChannel('com.yourcompany.app/motion');
static Future<void> startMotionUpdates() async {
try {
await _channel.invokeMethod('startMotionUpdates');
} on PlatformException catch (e) {
print("Failed to start motion updates: '${e.message}'.");
}
}
static Future<void> stopMotionUpdates() async {
try {
await _channel.invokeMethod('stopMotionUpdates');
} on PlatformException catch (e) {
print("Failed to stop motion updates: '${e.message}'.");
}
}
}