Skip to content

Commit

Permalink
Feature/seperate validator (#17)
Browse files Browse the repository at this point in the history
* Seperate man up validate function.

* Add man up validator file as part of ManUp

* Update readme and bump the version.

Co-authored-by: sparmar <sparmar@nextfaze.com>
  • Loading branch information
it-sam and sparmar authored May 18, 2021
1 parent 1b2f98e commit 71c6a65
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# manUp

## [2.0.2]

Separate manUp validator function to use it alone.

## [2.0.1]

Minor code changes.
Expand Down
1 change: 1 addition & 0 deletions lib/manup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ part 'src/exception.dart';
part 'src/metadata.dart';
part 'src/man_up_status.dart';
part 'src/man_up_service.dart';
part 'src/man_up_validator.dart';
part 'src/package_info_provider.dart';
part 'src/man_up_delegate.dart';
part 'src/ui/man_up_app_dialog.dart';
Expand Down
26 changes: 26 additions & 0 deletions lib/src/man_up_validator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
part of manup;

///
Future<ManUpStatus> validatePlatformData(
{required String version, required PlatformData platformData}) async {
//
if (!platformData.enabled) {
return ManUpStatus.disabled;
}

try {
Version currentVersion = Version.parse(version);
VersionConstraint latestVersion =
VersionConstraint.parse('>=${platformData.latestVersion}');
VersionConstraint minVersion =
VersionConstraint.parse('>=${platformData.minVersion}');
if (latestVersion.allows(currentVersion)) {
return ManUpStatus.latest;
} else if (minVersion.allows(currentVersion)) {
return ManUpStatus.supported;
}
return ManUpStatus.unsupported;
} catch (exception) {
throw ManUpException(exception.toString());
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: manup
description: Mandatory update for Flutter Apps.
version: 2.0.1
version: 2.0.2
homepage: https://github.com/NextFaze/flutter_manup

environment:
Expand Down

0 comments on commit 71c6a65

Please sign in to comment.