mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
[linting_tool] Stop duplication of rules in the same profile (#870)
This commit is contained in:
committed by
GitHub
parent
9986fe2f2c
commit
a68f3f57d6
@@ -59,8 +59,15 @@ class ProfilesStore extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addToExistingProfile(RulesProfile profile, Rule rule) async {
|
Future<void> addToExistingProfile(RulesProfile profile, Rule rule) async {
|
||||||
RulesProfile newProfile =
|
// TODO(abd99): Consider refactoring to LinkedHashSet/SplayTreeSet to avoid
|
||||||
RulesProfile(name: profile.name, rules: profile.rules..add(rule));
|
// 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);
|
await HiveService.updateBox<RulesProfile>(profile, newProfile, _boxName);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user