Skip to content

Commit dd8b9dd

Browse files
authored
fix: unable to get the device info in test mode (#4359)
1 parent 6e41359 commit dd8b9dd

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

frontend/appflowy_flutter/lib/startup/startup.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class FlowyRunner {
109109
// there's a flag named _enable in memory_leak_detector.dart. If it's false, the task will be ignored.
110110
MemoryLeakDetectorTask(),
111111
const DebugTask(),
112-
const DeviceOrApplicationInfoTask(),
112+
113113
// localization
114114
const InitLocalizationTask(),
115115
// init the app window
@@ -122,6 +122,9 @@ class FlowyRunner {
122122
// init the app widget
123123
// ignore in test mode
124124
if (!mode.isUnitTest) ...[
125+
// The DeviceOrApplicationInfoTask should be placed before the AppWidgetTask to fetch the app information.
126+
// It is unable to get the device information from the test environment.
127+
const DeviceOrApplicationInfoTask(),
125128
const HotKeyTask(),
126129
if (isSupabaseEnabled) InitSupabaseTask(),
127130
if (isAppFlowyCloudEnabled) InitAppFlowyCloudTask(),

frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@ class DeviceOrApplicationInfoTask extends LaunchTask {
1414

1515
@override
1616
Future<void> initialize(LaunchContext context) async {
17-
// Can't get the device info from test environment
18-
if (!context.env.isTest) {
19-
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
20-
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
21-
22-
if (Platform.isAndroid) {
23-
final androidInfo = await deviceInfoPlugin.androidInfo;
24-
androidSDKVersion = androidInfo.version.sdkInt;
25-
}
26-
27-
if (Platform.isAndroid || Platform.isIOS) {
28-
applicationVersion = packageInfo.version;
29-
buildNumber = packageInfo.buildNumber;
30-
}
17+
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
18+
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
19+
20+
if (Platform.isAndroid) {
21+
final androidInfo = await deviceInfoPlugin.androidInfo;
22+
androidSDKVersion = androidInfo.version.sdkInt;
23+
}
24+
25+
if (Platform.isAndroid || Platform.isIOS) {
26+
applicationVersion = packageInfo.version;
27+
buildNumber = packageInfo.buildNumber;
3128
}
3229
}
3330

0 commit comments

Comments
 (0)