check_for_update 1.0.1 check_for_update: ^1.0.1 copied to clipboard
Generates Dart code to automatically check for a new version of the current package.
check_for_update #
Generates Dart code to automatically check for a new version of the current package. Your project should depend on http
. The output code is platform-independent.
One final field is generated: PACKAGE_VERSION
- The package's active version.
Two methods are generated:
fetchCurrentVersion
: Asks the Pub API what the latest version of the package is.checkForUpdate
: ComparesPACKAGE_VERSION
to the result offetchCurrentVersion
and returnsnull
if no update is available. Otherwise, the new version will be returned.
Usage #
Generate from the project pubspec.yaml
:
import 'package:build_runner/build_runner.dart';
import 'package:check_for_update/builder.dart';
final PhaseGroup phaseGroup = new PhaseGroup.singleAction(
new CheckForUpdateBuilder(),
new InputSet('example', const ['pubspec.yaml']));
You can add the output to a subdirectory, i.e. lib
:
new CheckForUpdateBuilder(subDirectory: 'lib')
Overrides #
Specifying a specific package name to scan for updates:
new CheckForUpdateBuilder(packageName: 'shelf')
Specifying a custom Pub API URL:
new CheckForUpdateBuilder(pubApiRoot: 'https://foo.bar/pub-api')
Specifying a specific version to check against:
new CheckForUpdateBuilder(currentVersion: new Version(1, 2, 0, pre: 'alpha.6'))