Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ enum DevToolsStoreKeys {
class DevToolsUsage {
DevToolsUsage() {
LocalFileSystem.maybeMoveLegacyDevToolsStore();
_removeLegacyKeys();

properties = IOPersistentProperties(
storeName,
documentDirPath: LocalFileSystem.devToolsDir(),
);
_removeLegacyKeys();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] While moving this call fixes the late initialization error, the _removeLegacyKeys method (and the IOPersistentProperties.remove method it calls) does not currently persist changes to disk. This means legacy keys are only removed from memory and will reappear on the next run. Consider updating _removeLegacyKeys to use properties[key] = null or fixing IOPersistentProperties.remove to ensure the cleanup is permanent.

References
  1. The style guide emphasizes focusing on logic and architectural consistency. The current implementation of the cleanup logic is logically flawed as it lacks persistence. (link)

}

static const storeName = '.devtools';
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_shared/lib/src/server/file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class IOPersistentProperties {
}

void remove(String propertyName) {
_map.remove(propertyName);
this[propertyName] = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2026 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.

import 'dart:convert';
import 'dart:io';

import 'package:devtools_shared/src/server/file_system.dart';
import 'package:test/test.dart';

void main() {
group('IOPersistentProperties', () {
late Directory tempDir;
late IOPersistentProperties properties;
const storeName = 'test_store';

setUp(() {
tempDir = Directory.systemTemp.createTempSync('persistent_properties_test');
properties = IOPersistentProperties(
storeName,
documentDirPath: tempDir.path,
);
});

tearDown(() {
tempDir.deleteSync(recursive: true);
});

test('remove persists changes to disk', () {
properties['key1'] = 'value1';
properties['key2'] = 'value2';

final file = File('${tempDir.path}/$storeName');
expect(file.existsSync(), isTrue);

var content = file.readAsStringSync();
var json = (jsonDecode(content) as Map).cast<String, Object>();
expect(json['key1'], 'value1');
expect(json['key2'], 'value2');

properties.remove('key1');

content = file.readAsStringSync();
json = (jsonDecode(content) as Map).cast<String, Object>();
expect(json.containsKey('key1'), isFalse);
expect(json['key2'], 'value2');
});
});
}
32 changes: 16 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "22fdcc3cfeb9d974d7408718c4be15ec5e9b1b350088f3a6c88f154e74dd700d"
sha256: "1523ce62448ebac2c15a8ba5fbad8acac169788658a7dd2a1c2d9c2a9318b9a6"
url: "https://pub.dev"
source: hosted
version: "2.14.1"
version: "2.15.0"
built_collection:
dependency: transitive
description:
Expand All @@ -101,10 +101,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "0730c18c770d05636a8f945c32a4d7d81cb6e0f0148c8db4ad12e7748f7e49af"
sha256: "34e4067d30ce212937df995f03b69992eea683539ceeac7f679a1f1eba055b56"
url: "https://pub.dev"
source: hosted
version: "8.12.5"
version: "8.12.6"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -539,10 +539,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
url: "https://pub.dev"
source: hosted
version: "0.12.19"
version: "0.12.20"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -555,10 +555,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
sha256: df0c643f44ad098eb37988027a8e2b2b5a031fd3977f06bbfd3a76637e8df739
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.18.2"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -863,26 +863,26 @@ packages:
dependency: transitive
description:
name: test
sha256: "8d9ceddbab833f180fbefed08afa76d7c03513dfdba87ffcec2718b02bbcbf20"
sha256: ca578dc12bb8b2f40b67b7d3bd2fac4f31c01a6ff7130a14e2597b919934507f
url: "https://pub.dev"
source: hosted
version: "1.31.0"
version: "1.31.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
url: "https://pub.dev"
source: hosted
version: "0.7.11"
version: "0.7.12"
test_core:
dependency: transitive
description:
name: test_core
sha256: "1991d4cfe85d5043241acac92962c3977c8d2f2add1ee73130c7b286417d1d34"
sha256: d2e98ec12998368dc59ddd47ab709f2cd55acd6b66dc7db764455a44082f4bc5
url: "https://pub.dev"
source: hosted
version: "0.6.17"
version: "0.6.18"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -967,10 +967,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
sha256: "47a1b32ee755c3fcffa33db52a7258c137f97bdb2209a1075be847809fac4ccf"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "2.3.0"
vm_service:
dependency: transitive
description:
Expand Down
Loading