Presented by
Maintained by ACHMAD MAULANA
in_googleplay_update
Enables In App Updates on Android using the official Android APIs.
https://developer.android.com/guide/app-bundle/in-app-updates
Documentation
The following methods are exposed:
Future<AppUpdateInfo> checkForUpdate()
: Checks if there's an update availableFuture<void> performImmediateUpdate()
: Performs an immediate update (full-screen)Future<void> startFlexibleUpdate()
: Starts a flexible update (background download)Future<void> completeFlexibleUpdate()
: Actually installs an available flexible updateStream<String> flexibleUpdateStream()
: To listener flexible update state this return json stringbytes_downloaded: string, total_bytes_to_download
used this for make progress har download example: flexible progressbar
StreamBuilder<String>(
stream: InAppPlayUpdate.flexibleUpdateStream(),
builder: (context, snapshot) {
if (snapshot.hasData) {
String byteStringDownload = snapshot.data ?? '{}';
final byteDownload = json.decode(byteStringDownload);
return Column(
children: [
if(int.parse(byteDownload['bytes_downloaded']) == 0 && int.parse(byteDownload['total_bytes_to_download']) == 0)...[
ElevatedButton(
onPressed: () {
InAppPlayUpdate.completeFlexibleUpdate().then((_) {
showSnack("Success!");
}).catchError((e) {
showSnack(e.toString());
});
},
child: const Text('Complete flexible update'),
),
] else...[
LinearProgressIndicator(
value: (int.parse(byteDownload['bytes_downloaded']) / int.parse(byteDownload['total_bytes_to_download'])),
),
Text('${filesize(int.parse(byteDownload['bytes_downloaded']))}/${filesize(int.parse(byteDownload['total_bytes_to_download']))}',
style: const TextStyle(
fontSize: 14
),
)
]
],
);
} else {
return Column(
children: [
SizedBox(height: 10),
SizedBox(
width: 30,
height: 30,
child: CircularProgressIndicator(),
),
Text('This loading for download flexible indicator',
style: const TextStyle(
fontSize: 14
),
)
],
);
}
},
)
Please have a look in the example app on how to use it!
Android
This plugin integrates the official Android APIs to perform in app updated that were released in 2019: https://developer.android.com/guide/app-bundle/in-app-updates
Troubleshooting
Getting ERROR_API_NOT_AVAILABLE error
Be aware that this plugin cannot be tested locally. It must be installed via Google Play to work. Please check the official documentation about In App Updates from Google.