Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: unable to get the device info in test mode (#4359)
Lucas.Xudd8b9dd43e7d
diff --git a/frontend/appflowy_flutter/lib/startup/startup.dart b/frontend/appflowy_flutter/lib/startup/startup.dartindex d1e9c56190..390b73168e 100644--- a/frontend/appflowy_flutter/lib/startup/startup.dart+++ b/frontend/appflowy_flutter/lib/startup/startup.dart@@ -109,7 +109,7 @@ class FlowyRunner {// there's a flag named _enable in memory_leak_detector.dart. If it's false, the task will be ignored.MemoryLeakDetectorTask(),const DebugTask(),- const DeviceOrApplicationInfoTask(),+// localizationconst InitLocalizationTask(),// init the app window@@ -122,6 +122,9 @@ class FlowyRunner {// init the app widget// ignore in test modeif (!mode.isUnitTest) ...[+ // The DeviceOrApplicationInfoTask should be placed before the AppWidgetTask to fetch the app information.+ // It is unable to get the device information from the test environment.+ const DeviceOrApplicationInfoTask(),const HotKeyTask(),if (isSupabaseEnabled) InitSupabaseTask(),if (isAppFlowyCloudEnabled) InitAppFlowyCloudTask(),diff --git a/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart b/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dartindex 27c339ddb5..61225b8f58 100644--- a/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart+++ b/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart@@ -14,20 +14,17 @@ class DeviceOrApplicationInfoTask extends LaunchTask {@overrideFuture<void> initialize(LaunchContext context) async {- // Can't get the device info from test environment- if (!context.env.isTest) {- final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();- final PackageInfo packageInfo = await PackageInfo.fromPlatform();-- if (Platform.isAndroid) {- final androidInfo = await deviceInfoPlugin.androidInfo;- androidSDKVersion = androidInfo.version.sdkInt;- }-- if (Platform.isAndroid || Platform.isIOS) {- applicationVersion = packageInfo.version;- buildNumber = packageInfo.buildNumber;- }+ final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();+ final PackageInfo packageInfo = await PackageInfo.fromPlatform();++ if (Platform.isAndroid) {+ final androidInfo = await deviceInfoPlugin.androidInfo;+ androidSDKVersion = androidInfo.version.sdkInt;+ }++ if (Platform.isAndroid || Platform.isIOS) {+ applicationVersion = packageInfo.version;+ buildNumber = packageInfo.buildNumber;}}