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:
Bryan Oltman
2023-06-20 16:45:43 -04:00
committed by GitHub
parent 0057c7ea8d
commit 318d86e13f
9 changed files with 131 additions and 20 deletions
+24 -5
View File
@@ -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,
),
+1 -1
View File
@@ -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'