File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
lib/app/modules/splash/controllers Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // ignore_for_file: body_might_complete_normally_catch_error
2+
13import 'dart:io' ;
24
5+ import 'package:flutter/foundation.dart' ;
36import 'package:get/get.dart' ;
7+ import 'package:in_app_update/in_app_update.dart' ;
48import 'package:path_provider/path_provider.dart' ;
59import 'package:shared_preferences/shared_preferences.dart' ;
610import 'package:taskwarrior/app/models/storage.dart' ;
@@ -17,6 +21,7 @@ class SplashController extends GetxController {
1721 @override
1822 void onInit () async {
1923 super .onInit ();
24+ checkForUpdate ();
2025 initBaseDir ().then ((_) {
2126 _checkProfiles ();
2227 profilesMap.value = _profiles.profilesMap ();
@@ -100,4 +105,27 @@ class SplashController extends GetxController {
100105 Get .toNamed (Routes .ONBOARDING );
101106 }
102107 }
108+
109+ Future <void > checkForUpdate () async {
110+ try {
111+ AppUpdateInfo updateInfo = await InAppUpdate .checkForUpdate ();
112+ if (updateInfo.updateAvailability == UpdateAvailability .updateAvailable) {
113+ if (updateInfo.immediateUpdateAllowed) {
114+ InAppUpdate .performImmediateUpdate ().catchError ((e) {
115+ debugPrint (e.toString ());
116+ });
117+ } else if (updateInfo.flexibleUpdateAllowed) {
118+ InAppUpdate .startFlexibleUpdate ().then ((_) {
119+ InAppUpdate .completeFlexibleUpdate ().catchError ((e) {
120+ debugPrint (e.toString ());
121+ });
122+ }).catchError ((e) {
123+ debugPrint (e.toString ());
124+ });
125+ }
126+ }
127+ } catch (e) {
128+ debugPrint (e.toString ());
129+ }
130+ }
103131}
Original file line number Diff line number Diff line change @@ -640,6 +640,14 @@ packages:
640640 url: "https://pub.dev"
641641 source: hosted
642642 version: "4.6.0"
643+ in_app_update:
644+ dependency: "direct main"
645+ description:
646+ name: in_app_update
647+ sha256: "489572accaa55b51518b2d64676ca8c3c6d4c989fa53cf718001882237691a3c"
648+ url: "https://pub.dev"
649+ source: hosted
650+ version: "4.2.3"
643651 intl:
644652 dependency: "direct main"
645653 description:
You can’t perform that action at this time.
0 commit comments