@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
66import 'package:flutter/services.dart' ;
77import 'package:get/get.dart' ;
88import 'package:home_widget/home_widget.dart' ;
9+ import 'package:in_app_update/in_app_update.dart' ;
910
1011import 'package:loggy/loggy.dart' ;
1112import 'package:path_provider/path_provider.dart' ;
@@ -66,7 +67,6 @@ Future main([List<String> args = const []]) async {
6667 return const AppSetupPlaceholder ();
6768 }
6869 })));
69-
7070}
7171
7272Future <List <Directory >> getDirectories () async {
@@ -76,7 +76,6 @@ Future<List<Directory>> getDirectories() async {
7676 Directory baseDirectory =
7777 (directory != null ) ? Directory (directory) : defaultDirectory;
7878 return [defaultDirectory, baseDirectory];
79-
8079}
8180
8281Future init () async {
@@ -115,6 +114,28 @@ class _MyAppState extends State<MyApp> {
115114 helperFunction ();
116115 }
117116
117+ Future <void > checkForUpdate () async {
118+ // print('checking for Update');
119+ InAppUpdate .checkForUpdate ().then ((info) {
120+ setState (() {
121+ if (info.updateAvailability == UpdateAvailability .updateAvailable) {
122+ // print('update available');
123+ update ();
124+ }
125+ });
126+ }).catchError ((e) {
127+ // print(e.toString());
128+ });
129+ }
130+
131+ void update () async {
132+ // print('Updating');
133+ await InAppUpdate .startFlexibleUpdate ();
134+ InAppUpdate .completeFlexibleUpdate ().then ((_) {}).catchError ((e) {
135+ // print(e.toString());
136+ });
137+ }
138+
118139 void helperFunction () async {
119140 Uri ? myUri = await HomeWidget .initiallyLaunchedFromHomeWidget ();
120141 if (myUri != null ) {
@@ -165,15 +186,19 @@ class _MyAppState extends State<MyApp> {
165186
166187 home: isHomeWidgetTaskTapped == false
167188 ? CheckOnboardingStatus ()
168- : FutureBuilder (future: Future .delayed (const Duration (seconds: 2 )), builder: (context, snapshot) {
169- if (snapshot.connectionState == ConnectionState .waiting) {
170- return Scaffold (
171- backgroundColor:
172- AppSettings .isDarkMode ? Palette .kToDark.shade200 : Colors .white,
173- body: const Center (child: CircularProgressIndicator ()));
174- }
175- return DetailRoute (uuid);
176- },),
189+ : FutureBuilder (
190+ future: Future .delayed (const Duration (seconds: 2 )),
191+ builder: (context, snapshot) {
192+ if (snapshot.connectionState == ConnectionState .waiting) {
193+ return Scaffold (
194+ backgroundColor: AppSettings .isDarkMode
195+ ? Palette .kToDark.shade200
196+ : Colors .white,
197+ body: const Center (child: CircularProgressIndicator ()));
198+ }
199+ return DetailRoute (uuid);
200+ },
201+ ),
177202 );
178203 }));
179204 }
0 commit comments