Skip to content

Commit

Permalink
Merge pull request #3 from levin-riegner/1.0.0-nullsafety.1
Browse files Browse the repository at this point in the history
Null Safety Support
  • Loading branch information
Alqueraf authored Jun 10, 2021
2 parents 0028dc6 + d060257 commit 656982a
Show file tree
Hide file tree
Showing 17 changed files with 402 additions and 78 deletions.
23 changes: 11 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @dart=2.9

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lr_app_versioning/app_versioning.dart';
Expand Down Expand Up @@ -30,14 +28,14 @@ class MyApp extends StatelessWidget {
class Home extends StatefulWidget {
final AppVersioning appVersioning;

const Home({Key key, @required this.appVersioning}) : super(key: key);
const Home({required this.appVersioning});

@override
_HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
AppUpdateInfo appUpdateInfo;
AppUpdateInfo? appUpdateInfo;

bool isLoading = false;

Expand Down Expand Up @@ -73,28 +71,29 @@ class _HomeState extends State<Home> {
this.appUpdateInfo = appUpdateInfo;
});

// Check Update Required
final isUpdateRequired = appUpdateInfo.isUpdateAvailable &&
appUpdateInfo.updateType == AppUpdateType.Mandatory;
if (isUpdateRequired) {
_showUpdatePopup();
// Check Update Available
if (appUpdateInfo.isUpdateAvailable) {
_showUpdatePopup(appUpdateInfo.updateType == AppUpdateType.Mandatory);
}
}

Future<void> _trackVersions() async {
await widget.appVersioning.tracker.track();
}

_showUpdatePopup() {
_showUpdatePopup(bool isMandatory) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Container(
child: Column(
children: [
Text("Update required!"),
Text(isMandatory ? "Update required!" : "Optional update"),
TextButton(
onPressed: () => widget.appVersioning.launchUpdate(),
onPressed: () {
widget.appVersioning
.launchUpdate(updateInBackground: !isMandatory);
},
child: Text("OK"),
)
],
Expand Down
2 changes: 1 addition & 1 deletion example/lib/service_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ abstract class ServiceProvider {
return AppVersioning.apiService(
apiConfig: ApiConfig(
endpoints: ApiVersioningEndpoints(
"https://api-staging.avenew.org",
"https://api.example.org",
minimumVersioningEndpoint: "api/api-compatibility",
),
),
Expand Down
115 changes: 103 additions & 12 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
device_info:
dependency: transitive
description:
name: device_info
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
device_info_platform_interface:
dependency: transitive
description:
name: device_info_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -70,28 +84,35 @@ packages:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.3"
version: "1.2.1"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "4.0.1"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1+1"
version: "1.1.0"
firebase_remote_config:
dependency: transitive
description:
name: firebase_remote_config
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
version: "0.10.0+1"
firebase_remote_config_platform_interface:
dependency: transitive
description:
name: firebase_remote_config_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0+1"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -121,6 +142,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
in_app_update:
dependency: transitive
description:
name: in_app_update
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -165,6 +193,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
package_info_plus:
dependency: transitive
description:
name: package_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
package_info_plus_linux:
dependency: transitive
description:
name: package_info_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
package_info_plus_macos:
dependency: transitive
description:
name: package_info_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
package_info_plus_web:
dependency: transitive
description:
name: package_info_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
package_info_plus_windows:
dependency: transitive
description:
name: package_info_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -200,6 +270,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
platform:
dependency: transitive
description:
Expand All @@ -213,21 +290,14 @@ packages:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "2.0.0"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
shared_preferences:
dependency: transitive
description:
Expand Down Expand Up @@ -324,6 +394,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
upgrader:
dependency: transitive
description:
name: upgrader
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.1"
url_launcher:
dependency: transitive
description:
Expand Down Expand Up @@ -373,6 +450,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version:
dependency: transitive
description:
name: version
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
win32:
dependency: transitive
description:
Expand All @@ -387,6 +471,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
12 changes: 10 additions & 2 deletions lib/app_versioning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:lr_app_versioning/src/device/service/default_device_versioning_s
import 'package:lr_app_versioning/src/firebase/config/remote_config_keys.dart';
import 'package:lr_app_versioning/src/firebase/service/default_firebase_versioning_service.dart';
import 'package:lr_app_versioning/src/model/app_update_info.dart';
import 'package:lr_app_versioning/src/optional/default_optional_update_service.dart';
import 'package:lr_app_versioning/src/service/device_versioning_service.dart';
import 'package:lr_app_versioning/src/service/minimum_versioning_service.dart';
import 'package:lr_app_versioning/src/service/optional_update_service.dart';
import 'package:lr_app_versioning/src/util/version.dart';
import 'package:lr_app_versioning/src/util/version_tracker.dart';

Expand All @@ -22,6 +24,7 @@ export 'src/firebase/exports.dart';
export 'src/model/app_update_info.dart';
export 'src/model/exceptions.dart';
export 'src/model/minimum_versions.dart';
export 'src/optional/default_optional_update_service.dart';
export 'src/service/device_versioning_service.dart';
export 'src/service/minimum_versioning_service.dart';
export 'src/util/version.dart';
Expand All @@ -33,7 +36,7 @@ abstract class AppVersioning {

Future<AppUpdateInfo> getAppUpdateInfo();

void launchUpdate();
void launchUpdate({required bool updateInBackground});

void dispose();

Expand All @@ -44,6 +47,7 @@ abstract class AppVersioning {
return DefaultAppVersioning(
minimumVersioningService: DefaultApiVersioningService(apiConfig),
appUpdateService: DefaultDeviceVersioningService(updateConfig),
optionalUpdateService: DefaultOptionalUpdateService(updateConfig),
);
}

Expand All @@ -52,18 +56,22 @@ abstract class AppVersioning {
required UpdateConfig updateConfig,
}) {
return DefaultAppVersioning(
minimumVersioningService: DefaultFirebaseVersioningService(remoteConfigKeys),
minimumVersioningService:
DefaultFirebaseVersioningService(remoteConfigKeys),
appUpdateService: DefaultDeviceVersioningService(updateConfig),
optionalUpdateService: DefaultOptionalUpdateService(updateConfig),
);
}

factory AppVersioning({
required MinimumVersioningService minimumVersioningService,
required DeviceVersioningService appUpdateService,
required OptionalUpdateService optionalUpdateService,
}) {
return DefaultAppVersioning(
minimumVersioningService: minimumVersioningService,
appUpdateService: appUpdateService,
optionalUpdateService: optionalUpdateService,
);
}
}
Loading

0 comments on commit 656982a

Please sign in to comment.