diff --git a/packages/devtools_app/lib/src/config_specific/flutter/import_export/import_export.dart b/packages/devtools_app/lib/src/config_specific/flutter/import_export/import_export.dart index 1199fa0289e..1b916d7aa39 100644 --- a/packages/devtools_app/lib/src/config_specific/flutter/import_export/import_export.dart +++ b/packages/devtools_app/lib/src/config_specific/flutter/import_export/import_export.dart @@ -31,21 +31,30 @@ class ImportController { this._pushSnapshotScreenForImport, ); + static const repeatImportTimeBufferMs = 500; + final void Function(String screenId) _pushSnapshotScreenForImport; final NotificationService _notifications; - bool importing = false; + DateTime previousImportTime; // TODO(kenz): improve error handling here or in snapshot_screen.dart. void importData(Map json) { - if (importing) return; - importing = true; + // Do not allow two different imports within 500 ms of each other. This is a + // workaround for the fact that we get two drop events for the same file. + final now = DateTime.now(); + if (previousImportTime != null && + (now.millisecondsSinceEpoch - previousImportTime.millisecondsSinceEpoch) + .abs() < + repeatImportTimeBufferMs) { + return; + } + previousImportTime = now; final isDevToolsSnapshot = json[devToolsSnapshotKey]; if (isDevToolsSnapshot == null || !isDevToolsSnapshot) { _notifications.push(nonDevToolsFileMessage); - importing = false; return; } @@ -54,8 +63,6 @@ class ImportController { offlineDataJson = json; _notifications.push(attemptingToImportMessage(activeScreenId)); _pushSnapshotScreenForImport(activeScreenId); - - importing = false; } } diff --git a/packages/devtools_app/lib/src/flutter/theme.dart b/packages/devtools_app/lib/src/flutter/theme.dart index 86c2c161e0e..9de5e836f57 100644 --- a/packages/devtools_app/lib/src/flutter/theme.dart +++ b/packages/devtools_app/lib/src/flutter/theme.dart @@ -156,7 +156,9 @@ Color titleSolidBackgroundColor(ThemeData theme) { return theme.isDarkTheme ? devtoolsGrey[900] : devtoolsGrey[50]; } -final chartBackgroundColor = ThemedColor(Colors.grey[50], Colors.grey[850]); +// This is the same as Theme.of(context).scaffoldBackgroundColor, but we use +// this in places where we do not have access to the context. +final defaultBackgroundColor = ThemedColor(Colors.grey[50], Colors.grey[850]); const chartAccentColor = ThemedColor(Color(0xFFCCCCCC), Color(0xFF585858)); const chartTextColor = ThemedColor(Colors.black, Colors.white); diff --git a/packages/devtools_app/lib/src/memory/flutter/memory_chart.dart b/packages/devtools_app/lib/src/memory/flutter/memory_chart.dart index 53d82745bdf..92a71a04393 100644 --- a/packages/devtools_app/lib/src/memory/flutter/memory_chart.dart +++ b/packages/devtools_app/lib/src/memory/flutter/memory_chart.dart @@ -278,7 +278,7 @@ class MemoryChartState extends State with AutoDisposeMixin { ..textSize = 2.0; */ }, - backgroundColor: chartBackgroundColor, + backgroundColor: defaultBackgroundColor, doubleTapToZoomEnabled: false, // TODO(terry): For now disable zoom with double-click. pinchZoomEnabled: false, @@ -342,7 +342,7 @@ class MemoryChartState extends State with AutoDisposeMixin { ..textSize = 2.0; */ }, - backgroundColor: chartBackgroundColor, + backgroundColor: defaultBackgroundColor, // TOD(terry): Disable zoom via double-click. Consider +/- button // for a controlled zoom in/zoom out. scaleXEnabled: false, diff --git a/packages/devtools_app/lib/src/timeline/flutter/timeline_flame_chart.dart b/packages/devtools_app/lib/src/timeline/flutter/timeline_flame_chart.dart index 11f0dfc6801..40cd9ae3bea 100644 --- a/packages/devtools_app/lib/src/timeline/flutter/timeline_flame_chart.dart +++ b/packages/devtools_app/lib/src/timeline/flutter/timeline_flame_chart.dart @@ -626,7 +626,7 @@ class TimelineGridPainter extends CustomPainter { constraints.maxWidth, math.min(constraints.maxHeight, rowHeight), ), - Paint()..color = chartBackgroundColor, + Paint()..color = defaultBackgroundColor, ); // Paint the timeline grid lines and corresponding timestamps in the flame diff --git a/packages/devtools_app/lib/src/timeline/flutter/timeline_screen.dart b/packages/devtools_app/lib/src/timeline/flutter/timeline_screen.dart index 5dab18b420b..a44254b7b4a 100644 --- a/packages/devtools_app/lib/src/timeline/flutter/timeline_screen.dart +++ b/packages/devtools_app/lib/src/timeline/flutter/timeline_screen.dart @@ -111,7 +111,7 @@ class TimelineScreenBodyState extends State // Refresh data on page load if data is null. On subsequent tab changes, // this should not be called. - if (controller.data == null) { + if (controller.data == null && !offlineMode) { controller.refreshData(); } @@ -181,7 +181,7 @@ class TimelineScreenBodyState extends State timelineScreen, if (loadingOfflineData) Container( - color: Colors.grey[50], + color: Theme.of(context).scaffoldBackgroundColor, child: const Center( child: CircularProgressIndicator(), ),