My app, once published, is built into iOS and Android mobile apps thanks to the native app mobile shell.
I am looking for a way to display, withing the app, the build number which features in the pubspec.yaml file.
How would you suggest to achieve this ?
Of course I could set it before publishing, but then if I end up creating several successive builds with the same published version, there will be discrepancies.
Is there a way for the app to read a local text file somewhere, whether within the uibuilder folder or even above it ?
I don’t completely understand where you want to change the app version. In general as for me, I have changed the app version before release in pubspec.yaml, build.gradle(in app folder, for Android), and in Runner(for iOS).
At the bottom of the menu, you can see the version number being displayed.
I did this up to now by using a static function within the app :
However, this is not satisfactory because I need to remember to update it for each new version and keep it in sync with the pubspec.yaml file. And displaying the build number is even trickier, because I can build the mobile app several times with the same published web app.
So I am looking for a way for this display to get its information (version and build number) from the value in the pubspec.yaml file. Any ideas ?
After implementation of this you need to call native method in ui builder, and add implementation of your method in bridge_manager. Like this example, but with your own method name and implementation.
I will discuss this method with the team and maybe we will implement it into native shell. But at the moment you need to implement it yourself.
If you have any questions please let me know, Im happy to help you.
Current state it’s just field in my example that used for my task.
For your case you need to write your own logic. I will write code for your requirements a bit later.
I will only be able to test this once the EU cluster is back online.
However, when trying to implement it, I believe I found something missing in your steps above :
Also, this returns the version number, but could you confirm that returning the build number, I would have to define a similar case with buildNumber as follows ?
case _GET_CURRENT_BUILD_NUMBER:
{
if (info == null) {
info = await PackageInfo.fromPlatform();
}
result = info!.buildNumber;
return buildResponse(data: requestContainer, response: result);
}