Skip to content

Commit

Permalink
added update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel401 committed Jun 28, 2024
1 parent 4b7571b commit 7e94fee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
47 changes: 36 additions & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:home_widget/home_widget.dart';
import 'package:in_app_update/in_app_update.dart';

import 'package:loggy/loggy.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -66,7 +67,6 @@ Future main([List<String> args = const []]) async {
return const AppSetupPlaceholder();
}
})));

}

Future<List<Directory>> getDirectories() async {
Expand All @@ -76,7 +76,6 @@ Future<List<Directory>> getDirectories() async {
Directory baseDirectory =
(directory != null) ? Directory(directory) : defaultDirectory;
return [defaultDirectory, baseDirectory];

}

Future init() async {
Expand Down Expand Up @@ -115,6 +114,28 @@ class _MyAppState extends State<MyApp> {
helperFunction();
}

Future<void> checkForUpdate() async {
// print('checking for Update');
InAppUpdate.checkForUpdate().then((info) {
setState(() {
if (info.updateAvailability == UpdateAvailability.updateAvailable) {
// print('update available');
update();
}
});
}).catchError((e) {
// print(e.toString());
});
}

void update() async {
// print('Updating');
await InAppUpdate.startFlexibleUpdate();
InAppUpdate.completeFlexibleUpdate().then((_) {}).catchError((e) {
// print(e.toString());
});
}

void helperFunction() async {
Uri? myUri = await HomeWidget.initiallyLaunchedFromHomeWidget();
if (myUri != null) {
Expand Down Expand Up @@ -165,15 +186,19 @@ class _MyAppState extends State<MyApp> {

home: isHomeWidgetTaskTapped == false
? CheckOnboardingStatus()
: FutureBuilder(future: Future.delayed(const Duration(seconds: 2)), builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
backgroundColor:
AppSettings.isDarkMode ? Palette.kToDark.shade200 : Colors.white,
body: const Center(child: CircularProgressIndicator()));
}
return DetailRoute(uuid);
},),
: FutureBuilder(
future: Future.delayed(const Duration(seconds: 2)),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
backgroundColor: AppSettings.isDarkMode
? Palette.kToDark.shade200
: Colors.white,
body: const Center(child: CircularProgressIndicator()));
}
return DetailRoute(uuid);
},
),
);
}));
}
Expand Down
12 changes: 6 additions & 6 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: taskwarrior
description: A new Flutter project.
version: 1.0.0+1
version: 2.0.0+2
publish_to: "none" # Remove this line if you wish to publish to pub.dev

environment:
Expand All @@ -14,9 +14,11 @@ environment:
# versions available, run `flutter pub outdated`.
dependencies:
connectivity_plus: ^5.0.2
crypto: ^3.0.1
cupertino_icons: ^1.0.5
date_format: ^2.0.6
double_back_to_close_app: ^2.1.0
file_picker: ^6.1.1
file_picker_writable: ^2.0.3
file_selector: ^0.9.4
flutter:
Expand All @@ -25,20 +27,21 @@ dependencies:
flutter_local_notifications: ^16.2.0
flutter_native_splash: ^2.1.2+1
flutter_native_timezone: ^2.0.0
flutter_platform_widgets: ^6.0.2
flutter_slidable: ^3.0.1
flutter_svg: ^2.0.7
get: ^4.6.5
google_fonts: ^6.1.0
hive: ^2.2.1
hive_flutter: ^1.1.0
home_widget: ^0.4.0
home_widget: ^0.6.0
http: ^1.1.0
import_sorter: ^4.6.0
in_app_update: ^4.2.3
intl: ^0.18.0
loggy: ^2.0.1+1
package_info_plus: ^4.0.2
pem: ^2.0.1
# permission_handler: ^10.2.0
permission_handler:
git:
url: https://github.com/bvoq/flutter-permission-handler.git
Expand All @@ -53,9 +56,6 @@ dependencies:
tutorial_coach_mark: ^1.2.11
url_launcher: ^6.1.14
uuid: ^4.2.2
crypto: ^3.0.1
flutter_platform_widgets: ^6.0.2
file_picker: ^6.1.1

dev_dependencies:
build_runner: ^2.1.11
Expand Down

0 comments on commit 7e94fee

Please sign in to comment.