20240903 pre release
This commit is contained in:
29
lib/services/motion_service.dart
Normal file
29
lib/services/motion_service.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class MotionService {
|
||||
static const MethodChannel _channel = MethodChannel('net.sumasen.gifunavi/motion');
|
||||
|
||||
static Future<void> startMotionUpdates() async {
|
||||
if (Platform.isIOS) {
|
||||
try {
|
||||
await _channel.invokeMethod('startMotionUpdates');
|
||||
} on PlatformException catch (e) {
|
||||
print("Failed to start motion updates: '${e.message}'.");
|
||||
}
|
||||
} else{
|
||||
// Android の場合は何もしない、またはAndroid向けの代替実装を行う
|
||||
print("Motion updates not supported on this platform");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> stopMotionUpdates() async {
|
||||
if (Platform.isIOS) {
|
||||
try {
|
||||
await _channel.invokeMethod('stopMotionUpdates');
|
||||
} on PlatformException catch (e) {
|
||||
print("Failed to stop motion updates: '${e.message}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user