25-1/31/1

This commit is contained in:
Hamza-Ayed
2025-01-31 14:57:17 +03:00
parent fd0002ce97
commit 13a7c3db81
100 changed files with 469 additions and 436 deletions

View File

@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class LiveActivityScreen extends StatefulWidget {
@override
_LiveActivityScreenState createState() => _LiveActivityScreenState();
}
class _LiveActivityScreenState extends State<LiveActivityScreen> {
static const platform = MethodChannel('live_activity_channel');
Future<void> _startLiveActivity() async {
try {
await platform.invokeMethod('startLiveActivity');
} on PlatformException catch (e) {
print("Failed to start Live Activity: '${e.message}'.");
}
}
Future<void> _updateLiveActivity(double progress) async {
try {
await platform.invokeMethod('updateLiveActivity', {"progress": progress});
} on PlatformException catch (e) {
print("Failed to update Live Activity: '${e.message}'.");
}
}
Future<void> _endLiveActivity() async {
try {
await platform.invokeMethod('endLiveActivity');
} on PlatformException catch (e) {
print("Failed to end Live Activity: '${e.message}'.");
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Live Activity Test")),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: _startLiveActivity,
child: Text("Start Live Activity"),
),
ElevatedButton(
onPressed: () => _updateLiveActivity(0.5),
child: Text("Update Progress to 50%"),
),
ElevatedButton(
onPressed: _endLiveActivity,
child: Text("End Live Activity"),
),
],
),
);
}
}