feat: add shorebird_current_boot_patch_number function (#36)
* feat: add shorebird_current_boot_patch_number function * Continue support for next_patch_version * rename, return null in case of 0
This commit is contained in:
@@ -32,18 +32,22 @@ class MyHomePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
final ShorebirdCodePush _shorebirdCodePush = ShorebirdCodePush();
|
||||
int? _patchVersion;
|
||||
final _shorebirdCodePush = ShorebirdCodePush();
|
||||
int? _currentPatchVersion;
|
||||
int? _nextPatchVersion;
|
||||
bool _isCheckingForUpdate = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_shorebirdCodePush.currentPatchVersion().then((version) {
|
||||
_shorebirdCodePush.currentPatchNumber().then((currentPatchVersion) async {
|
||||
final nextPatchVersion = await _shorebirdCodePush.nextPatchNumber();
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
setState(() {
|
||||
_patchVersion = version;
|
||||
_currentPatchVersion = currentPatchVersion;
|
||||
_nextPatchVersion = nextPatchVersion;
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -83,9 +87,24 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
children: <Widget>[
|
||||
const Text('Current patch version:'),
|
||||
Text(
|
||||
_patchVersion != null ? _patchVersion.toString() : 'none',
|
||||
_currentPatchVersion != null
|
||||
? _currentPatchVersion.toString()
|
||||
: 'none',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
if (_nextPatchVersion != null &&
|
||||
_nextPatchVersion != _currentPatchVersion)
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const Text('Next patch version:'),
|
||||
Text(
|
||||
_nextPatchVersion.toString(),
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
|
||||
@@ -2,7 +2,7 @@ name: shorebird_code_push_example
|
||||
description: An example demonstrating how to use the shorebird_code_push package
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.0.0+15
|
||||
version: 1.0.0+17
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.5 <4.0.0'
|
||||
|
||||
Reference in New Issue
Block a user