full_screen_intent 0.0.1 full_screen_intent: ^0.0.1 copied to clipboard
A plugin to open an app page even if the app is closed
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:full_screen_intent/full_screen_intent.dart';
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await AndroidAlarmManager.initialize();
runApp(App());
}
@pragma('vm:entry-point')
void backgroundTask() async {
await FullScreenIntent().openFullScreenWidget();
}
class App extends StatelessWidget {
Future<void> scheduleOpen() async {
DateTime time = DateTime.now().add(const Duration(seconds: 10));
int id = time.hour * 100 + time.minute;
await AndroidAlarmManager.oneShotAt(
time,
id,
backgroundTask,
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Plugin Example'),
),
body: Center(
child: ElevatedButton(
onPressed: () => scheduleOpen(),
child: Text('Open Full Screen Widget'),
),
),
),
onGenerateRoute: (settings) {
if (settings.name == '/fullscreen') {
return MaterialPageRoute(
builder: (context) => FullScreenWidget(),
);
}
},
);
}
}
class FullScreenWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Full Screen Widget'),
),
body: Center(
child: Text('This is a full-screen Flutter widget!'),
),
);
}
}