update to add resume app from sleep
This commit is contained in:
@ -1,16 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_binding.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/utils/string_values.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:is_lock_screen/is_lock_screen.dart';
|
||||
|
||||
void main() async {
|
||||
|
||||
@ -32,12 +28,39 @@ void main() async {
|
||||
value: 'cacheFirst',
|
||||
);
|
||||
|
||||
runApp(MyApp());
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
// This widget is the root of your application.
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance?.addObserver(this);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||
super.didChangeAppLifecycleState(state);
|
||||
if (state == AppLifecycleState.inactive) {
|
||||
print('app inactive, is lock screen: ${await isLockScreen()}');
|
||||
} else if (state == AppLifecycleState.resumed) {
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
destinationController.initGPS();
|
||||
print('app resumed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetMaterialApp(
|
||||
@ -49,7 +72,6 @@ class MyApp extends StatelessWidget {
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
textTheme: GoogleFonts.muliTextTheme(),
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
defaultTransition: Transition.cupertino,
|
||||
|
||||
Reference in New Issue
Block a user