1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

[linting_tool] Stop duplication of rules in the same profile (#870)

This commit is contained in:
Abdullah Deshmukh
2021-08-11 08:16:16 +05:30
committed by GitHub
parent 9986fe2f2c
commit a68f3f57d6

View File

@@ -59,8 +59,15 @@ class ProfilesStore extends ChangeNotifier {
}
Future<void> addToExistingProfile(RulesProfile profile, Rule rule) async {
RulesProfile newProfile =
RulesProfile(name: profile.name, rules: profile.rules..add(rule));
// TODO(abd99): Consider refactoring to LinkedHashSet/SplayTreeSet to avoid
// duplication automatically.
// ref: https://github.com/flutter/samples/pull/870#discussion_r685666792
var rules = profile.rules;
if (!rules.contains(rule)) {
rules.add(rule);
}
RulesProfile newProfile = RulesProfile(name: profile.name, rules: rules);
await HiveService.updateBox<RulesProfile>(profile, newProfile, _boxName);