@@ -3,6 +3,7 @@ import 'package:firebase_core/firebase_core.dart' as firebase_core;
3
3
import 'package:firebase_messaging/firebase_messaging.dart' as firebase_messaging;
4
4
import 'package:flutter/foundation.dart' ;
5
5
import 'package:flutter_local_notifications/flutter_local_notifications.dart' ;
6
+ import 'package:package_info_plus/package_info_plus.dart' as package_info_plus;
6
7
import 'package:url_launcher/url_launcher.dart' as url_launcher;
7
8
8
9
import '../host/android_notifications.dart' ;
@@ -72,6 +73,12 @@ abstract class ZulipBinding {
72
73
/// This wraps [device_info_plus.DeviceInfoPlugin.deviceInfo] .
73
74
BaseDeviceInfo get deviceInfo;
74
75
76
+ /// Provides application package information,
77
+ /// via package:package_info_plus.
78
+ ///
79
+ /// This wraps [package_info_plus.PackageInfo.fromPlatform] .
80
+ PackageInfo get packageInfo;
81
+
75
82
/// Prepare the app's [GlobalStore] , loading the necessary data.
76
83
///
77
84
/// Generally the app should call this function only once.
@@ -152,6 +159,17 @@ class IosDeviceInfo extends BaseDeviceInfo {
152
159
IosDeviceInfo ({required this .systemVersion});
153
160
}
154
161
162
+ /// Like [package_info_plus.PackageInfo] , but without things we don't use.
163
+ class PackageInfo {
164
+ final String version;
165
+ final String buildNumber;
166
+
167
+ PackageInfo ({
168
+ required this .version,
169
+ required this .buildNumber,
170
+ });
171
+ }
172
+
155
173
/// A concrete binding for use in the live application.
156
174
///
157
175
/// The global store returned by [loadGlobalStore] , and consequently by
@@ -165,7 +183,10 @@ class LiveZulipBinding extends ZulipBinding {
165
183
static Future <LiveZulipBinding > ensureInitialized () async {
166
184
if (ZulipBinding ._instance == null ) {
167
185
final binding = LiveZulipBinding ();
168
- await binding._prefetchDeviceInfo ();
186
+ await Future .wait (< Future <void >> [
187
+ binding._prefetchDeviceInfo (),
188
+ binding._prefetchPackageInfo (),
189
+ ]);
169
190
}
170
191
return ZulipBinding .instance as LiveZulipBinding ;
171
192
}
@@ -174,6 +195,10 @@ class LiveZulipBinding extends ZulipBinding {
174
195
BaseDeviceInfo get deviceInfo => _deviceInfo! ;
175
196
BaseDeviceInfo ? _deviceInfo;
176
197
198
+ @override
199
+ PackageInfo get packageInfo => _packageInfo! ;
200
+ PackageInfo ? _packageInfo;
201
+
177
202
Future <void > _prefetchDeviceInfo () async {
178
203
final info = await device_info_plus.DeviceInfoPlugin ().deviceInfo;
179
204
_deviceInfo = switch (info) {
@@ -183,6 +208,14 @@ class LiveZulipBinding extends ZulipBinding {
183
208
};
184
209
}
185
210
211
+ Future <void > _prefetchPackageInfo () async {
212
+ final info = await package_info_plus.PackageInfo .fromPlatform ();
213
+ _packageInfo = PackageInfo (
214
+ version: info.version,
215
+ buildNumber: info.buildNumber,
216
+ );
217
+ }
218
+
186
219
@override
187
220
Future <GlobalStore > loadGlobalStore () {
188
221
return LiveGlobalStore .load ();
0 commit comments