set literal conversions (#27811)

This commit is contained in:
Phil Quitslund 2019-03-06 11:05:16 -08:00 committed by GitHub
parent 608b03c79b
commit 802eca29d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 133 additions and 138 deletions

View file

@ -120,7 +120,7 @@ linter:
# - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
# - prefer_collection_literals # temporary until all platforms support set literals
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables

View file

@ -401,7 +401,7 @@ Set<String> _findFlutterDependencies(String srcPath, List<String> errors, { bool
return Directory(srcPath).listSync(recursive: true).where((FileSystemEntity entity) {
return entity is File && path.extension(entity.path) == '.dart';
}).map<Set<String>>((FileSystemEntity entity) {
final Set<String> result = Set<String>();
final Set<String> result = <String>{};
final File file = entity;
for (String line in file.readAsLinesSync()) {
Match match = _importPattern.firstMatch(line);
@ -419,7 +419,7 @@ Set<String> _findFlutterDependencies(String srcPath, List<String> errors, { bool
}
return result;
}).reduce((Set<String> value, Set<String> element) {
value ??= Set<String>();
value ??= <String>{};
value.addAll(element);
return value;
});
@ -434,7 +434,7 @@ List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
final List<T> result = _deepSearch<T>(
map,
key,
(seen == null ? Set<T>.from(<T>[start]) : Set<T>.from(seen))..add(key),
(seen == null ? <T>{start} : Set<T>.from(seen))..add(key),
);
if (result != null) {
result.insert(0, start);
@ -543,7 +543,7 @@ Future<void> _verifyGeneratedPluginRegistrants(String flutterRoot) async {
}
}
final Set<String> outOfDate = Set<String>();
final Set<String> outOfDate = <String>{};
for (String package in packageToRegistrants.keys) {
final Map<File, String> fileToContent = <File, String>{};

View file

@ -1382,7 +1382,7 @@ String zalgo(math.Random random, int targetLength, { bool includeSpacingCombinin
0x16F7E, 0x1D165, 0x1D166, 0x1D16D, 0x1D16E, 0x1D16F, 0x1D170,
0x1D171, 0x1D172,
];
final Set<int> these = Set<int>();
final Set<int> these = <int>{};
int combiningCount = enclosingCombiningMarks.length + nonspacingCombiningMarks.length;
if (includeSpacingCombiningMarks)
combiningCount += spacingCombiningMarks.length;

View file

@ -80,7 +80,7 @@ final Map<LocaleInfo, Map<String, dynamic>> localeToResourceAttributes = <Locale
/// the first Hant Chinese locale as a default by repeating the data. If an
/// explicit match is later found, we can reference this set to see if we should
/// overwrite the existing assumed data.
final Set<LocaleInfo> assumedLocales = Set<LocaleInfo>();
final Set<LocaleInfo> assumedLocales = <LocaleInfo>{};
/// Return `s` as a Dart-parseable raw string in single or double quotes.
///
@ -124,15 +124,15 @@ String generateTranslationBundles() {
final Map<String, Set<String>> languageToScriptCodes = <String, Set<String>>{};
// Used to calculate if there are any corresponding countries for a given language and script.
final Map<LocaleInfo, Set<String>> languageAndScriptToCountryCodes = <LocaleInfo, Set<String>>{};
final Set<String> allResourceIdentifiers = Set<String>();
final Set<String> allResourceIdentifiers = <String>{};
for (LocaleInfo locale in localeToResources.keys.toList()..sort()) {
if (locale.scriptCode != null) {
languageToScriptCodes[locale.languageCode] ??= Set<String>();
languageToScriptCodes[locale.languageCode] ??= <String>{};
languageToScriptCodes[locale.languageCode].add(locale.scriptCode);
}
if (locale.countryCode != null && locale.scriptCode != null) {
final LocaleInfo key = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode);
languageAndScriptToCountryCodes[key] ??= Set<String>();
languageAndScriptToCountryCodes[key] ??= <String>{};
languageAndScriptToCountryCodes[key].add(locale.countryCode);
}
languageToLocales[locale.languageCode] ??= <LocaleInfo>[];

View file

@ -71,7 +71,7 @@ const Map<String, String> kIdentifierRewrites = <String, String>{
};
final Set<String> kMirroredIcons = Set<String>.from(<String>[
const Set<String> kMirroredIcons = <String>{
// This list is obtained from:
// http://google.github.io/material-design-icons/#icons-in-rtl
'arrow_back',
@ -145,7 +145,7 @@ final Set<String> kMirroredIcons = Set<String>.from(<String>[
'view_list',
'view_quilt',
'wrap_text',
]);
};
void main(List<String> args) {
// If we're run from the `tools` dir, set the cwd to the repo root.

View file

@ -54,20 +54,20 @@ const Map<String, String> _avatars = <String, String>{
'customer': 'people/square/peter.png',
};
final Map<String, Set<String>> _toolActions = <String, Set<String>>{
'hammer': Set<String>()..addAll(<String>['flake', 'fragment', 'splinter']),
'chisel': Set<String>()..addAll(<String>['flake', 'nick', 'splinter']),
'fryer': Set<String>()..addAll(<String>['fry']),
'fabricator': Set<String>()..addAll(<String>['solder']),
'customer': Set<String>()..addAll(<String>['cash in', 'eat']),
const Map<String, Set<String>> _toolActions = <String, Set<String>>{
'hammer': <String>{'flake', 'fragment', 'splinter'},
'chisel': <String>{'flake', 'nick', 'splinter'},
'fryer': <String>{'fry'},
'fabricator': <String>{'solder'},
'customer': <String>{'cash in', 'eat'},
};
final Map<String, Set<String>> _materialActions = <String, Set<String>>{
'poker': Set<String>()..addAll(<String>['cash in']),
'tortilla': Set<String>()..addAll(<String>['fry', 'eat']),
'fish and': Set<String>()..addAll(<String>['fry', 'eat']),
'micro': Set<String>()..addAll(<String>['solder', 'fragment']),
'wood': Set<String>()..addAll(<String>['flake', 'cut', 'splinter', 'nick']),
const Map<String, Set<String>> _materialActions = <String, Set<String>>{
'poker': <String>{'cash in'},
'tortilla': <String>{'fry', 'eat'},
'fish and': <String>{'fry', 'eat'},
'micro': <String>{'solder', 'fragment'},
'wood': <String>{'flake', 'cut', 'splinter', 'nick'},
};
class _ChipsTile extends StatelessWidget {
@ -134,12 +134,12 @@ class _ChipDemoState extends State<ChipDemo> {
_reset();
}
final Set<String> _materials = Set<String>();
final Set<String> _materials = <String>{};
String _selectedMaterial = '';
String _selectedAction = '';
final Set<String> _tools = Set<String>();
final Set<String> _selectedTools = Set<String>();
final Set<String> _actions = Set<String>();
final Set<String> _tools = <String>{};
final Set<String> _selectedTools = <String>{};
final Set<String> _actions = <String>{};
bool _showShapeBorder = false;
// Initialize members with the default data.
@ -262,7 +262,7 @@ class _ChipDemoState extends State<ChipDemo> {
);
}).toList();
Set<String> allowedActions = Set<String>();
Set<String> allowedActions = <String>{};
if (_selectedMaterial != null && _selectedMaterial.isNotEmpty) {
for (String tool in _selectedTools) {
allowedActions.addAll(_toolActions[tool]);

View file

@ -21,7 +21,7 @@ const double _kAppBarHeight = 128.0;
const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size
const double _kRecipePageMaxWidth = 500.0;
final Set<Recipe> _favoriteRecipes = Set<Recipe>();
final Set<Recipe> _favoriteRecipes = <Recipe>{};
final ThemeData _kTheme = ThemeData(
brightness: Brightness.light,

View file

@ -193,7 +193,7 @@ class CupertinoPageRoute<T> extends PageRoute<T> {
/// * [popGestureEnabled], which returns true if a user-triggered pop gesture
/// would be allowed.
static bool isPopGestureInProgress(PageRoute<dynamic> route) => _popGestureInProgress.contains(route);
static final Set<PageRoute<dynamic>> _popGestureInProgress = Set<PageRoute<dynamic>>();
static final Set<PageRoute<dynamic>> _popGestureInProgress = <PageRoute<dynamic>>{};
/// True if a Cupertino pop gesture is currently underway for this route.
///

View file

@ -70,7 +70,7 @@ class _TrackedAnnotation {
///
/// This is used to detect layers that used to have the mouse pointer inside
/// them, but now no longer do (to facilitate exit notification).
Set<int> activeDevices = Set<int>();
Set<int> activeDevices = <int>{};
}
/// Describes a function that finds an annotation given an offset in logical

View file

@ -965,10 +965,10 @@ class _DialPainter extends CustomPainter {
textDirection: textDirection,
onTap: label.onTap,
),
tags: Set<SemanticsTag>.from(const <SemanticsTag>[
tags: <SemanticsTag>{
// Used by tests to find this node.
SemanticsTag('dial-label'),
]),
const SemanticsTag('dial-label'),
},
);
nodes.add(node);
labelTheta += labelThetaIncrement;

View file

@ -183,7 +183,7 @@ abstract class MultiChildLayoutDelegate {
Set<RenderBox> debugPreviousChildrenNeedingLayout;
assert(() {
debugPreviousChildrenNeedingLayout = _debugChildrenNeedingLayout;
_debugChildrenNeedingLayout = Set<RenderBox>();
_debugChildrenNeedingLayout = <RenderBox>{};
return true;
}());

View file

@ -921,7 +921,7 @@ class PipelineOwner {
}
bool _debugDoingSemantics = false;
final Set<RenderObject> _nodesNeedingSemantics = Set<RenderObject>();
final Set<RenderObject> _nodesNeedingSemantics = <RenderObject>{};
/// Update the semantics for render objects marked as needing a semantics
/// update.
@ -2422,7 +2422,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
final bool producesForkingFragment = !config.hasBeenAnnotated && !config.isSemanticBoundary;
final List<_InterestingSemanticsFragment> fragments = <_InterestingSemanticsFragment>[];
final Set<_InterestingSemanticsFragment> toBeMarkedExplicit = Set<_InterestingSemanticsFragment>();
final Set<_InterestingSemanticsFragment> toBeMarkedExplicit = <_InterestingSemanticsFragment>{};
final bool childrenMergeIntoParent = mergeIntoParent || config.isMergingSemanticsOfDescendants;
// When set to true there's currently not enough information in this subtree
@ -3244,7 +3244,7 @@ abstract class _InterestingSemanticsFragment extends _SemanticsFragment {
void addTags(Iterable<SemanticsTag> tags) {
if (tags == null || tags.isEmpty)
return;
_tagsForChildren ??= Set<SemanticsTag>();
_tagsForChildren ??= <SemanticsTag>{};
_tagsForChildren.addAll(tags);
}

View file

@ -481,7 +481,7 @@ class _AndroidViewGestureRecognizer extends OneSequenceGestureRecognizer {
// Pointer for which we have already won the arena, events for pointers in this set are
// immediately dispatched to the Android view.
final Set<int> forwardedPointers = Set<int>();
final Set<int> forwardedPointers = <int>{};
// We use OneSequenceGestureRecognizers as they support gesture arena teams.
// TODO(amirh): get a list of GestureRecognizers here.

View file

@ -1284,7 +1284,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
return true;
}());
assert(() {
final Set<SemanticsNode> seenChildren = Set<SemanticsNode>();
final Set<SemanticsNode> seenChildren = <SemanticsNode>{};
for (SemanticsNode child in newChildren)
assert(seenChildren.add(child)); // check for duplicate adds
return true;
@ -1742,7 +1742,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
double scrollExtentMin = _scrollExtentMin;
final double elevation = _elevation;
double thickness = _thickness;
final Set<int> customSemanticsActionIds = Set<int>();
final Set<int> customSemanticsActionIds = <int>{};
for (CustomSemanticsAction action in _customSemanticsActions.keys)
customSemanticsActionIds.add(CustomSemanticsAction.getIdentifier(action));
if (hintOverrides != null) {
@ -1781,7 +1781,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
if (decreasedValue == '' || decreasedValue == null)
decreasedValue = node._decreasedValue;
if (node.tags != null) {
mergedTags ??= Set<SemanticsTag>();
mergedTags ??= <SemanticsTag>{};
mergedTags.addAll(node.tags);
}
if (node._customSemanticsActions != null) {
@ -2270,7 +2270,7 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> {
}
final List<int> sortedIds = <int>[];
final Set<int> visitedIds = Set<int>();
final Set<int> visitedIds = <int>{};
final List<SemanticsNode> startNodes = nodes.toList()..sort((SemanticsNode a, SemanticsNode b) {
final Offset aTopLeft = _pointInParentCoordinates(a, a.rect.topLeft);
final Offset bTopLeft = _pointInParentCoordinates(b, b.rect.topLeft);
@ -2410,9 +2410,9 @@ class _TraversalSortNode implements Comparable<_TraversalSortNode> {
/// obtain a [SemanticsHandle]. This will create a [SemanticsOwner] if
/// necessary.
class SemanticsOwner extends ChangeNotifier {
final Set<SemanticsNode> _dirtyNodes = Set<SemanticsNode>();
final Set<SemanticsNode> _dirtyNodes = <SemanticsNode>{};
final Map<int, SemanticsNode> _nodes = <int, SemanticsNode>{};
final Set<SemanticsNode> _detachedNodes = Set<SemanticsNode>();
final Set<SemanticsNode> _detachedNodes = <SemanticsNode>{};
final Map<int, CustomSemanticsAction> _actions = <int, CustomSemanticsAction>{};
/// The root node of the semantics tree, if any.
@ -2432,7 +2432,7 @@ class SemanticsOwner extends ChangeNotifier {
void sendSemanticsUpdate() {
if (_dirtyNodes.isEmpty)
return;
final Set<int> customSemanticsActionIds = Set<int>();
final Set<int> customSemanticsActionIds = <int>{};
final List<SemanticsNode> visitedNodes = <SemanticsNode>[];
while (_dirtyNodes.isNotEmpty) {
final List<SemanticsNode> localDirtyNodes = _dirtyNodes.where((SemanticsNode node) => !_detachedNodes.contains(node)).toList();
@ -3551,7 +3551,7 @@ class SemanticsConfiguration {
/// * [RenderSemanticsGestureHandler.excludeFromScrolling] for an example of
/// how tags are used.
void addTagForChildren(SemanticsTag tag) {
_tagsForChildren ??= Set<SemanticsTag>();
_tagsForChildren ??= <SemanticsTag>{};
_tagsForChildren.add(tag);
}

View file

@ -478,7 +478,7 @@ class RawKeyboard {
}
}
final Set<LogicalKeyboardKey> _keysPressed = Set<LogicalKeyboardKey>();
final Set<LogicalKeyboardKey> _keysPressed = <LogicalKeyboardKey>{};
/// Returns the set of keys currently pressed.
Set<LogicalKeyboardKey> get keysPressed {

View file

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:collection';
import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
@ -278,7 +276,7 @@ class AnimatedSwitcher extends StatefulWidget {
class _AnimatedSwitcherState extends State<AnimatedSwitcher> with TickerProviderStateMixin {
_ChildEntry _currentEntry;
final Set<_ChildEntry> _outgoingEntries = LinkedHashSet<_ChildEntry>();
final Set<_ChildEntry> _outgoingEntries = <_ChildEntry>{};
List<Widget> _outgoingWidgets = const <Widget>[];
int _childNumber = 0;

View file

@ -83,7 +83,7 @@ class Form extends StatefulWidget {
/// Typically obtained via [Form.of].
class FormState extends State<Form> {
int _generation = 0;
final Set<FormFieldState<dynamic>> _fields = Set<FormFieldState<dynamic>>();
final Set<FormFieldState<dynamic>> _fields = <FormFieldState<dynamic>>{};
// Called when a form field has changed. This will cause all form fields
// to rebuild, useful if form fields have interdependencies.

View file

@ -44,7 +44,7 @@ Future<Map<Type, dynamic>> _loadAll(Locale locale, Iterable<LocalizationsDelegat
// Only load the first delegate for each delegate type that supports
// locale.languageCode.
final Set<Type> types = Set<Type>();
final Set<Type> types = <Type>{};
final List<LocalizationsDelegate<dynamic>> delegates = <LocalizationsDelegate<dynamic>>[];
for (LocalizationsDelegate<dynamic> delegate in allDelegates) {
if (!types.contains(delegate.type) && delegate.isSupported(locale)) {

View file

@ -1465,7 +1465,7 @@ class Navigator extends StatefulWidget {
class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
final GlobalKey<OverlayState> _overlayKey = GlobalKey<OverlayState>();
final List<Route<dynamic>> _history = <Route<dynamic>>[];
final Set<Route<dynamic>> _poppedRoutes = Set<Route<dynamic>>();
final Set<Route<dynamic>> _poppedRoutes = <Route<dynamic>>{};
/// The [FocusScopeNode] for the [FocusScope] that encloses the routes.
final FocusScopeNode focusScopeNode = FocusScopeNode();
@ -2145,7 +2145,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
}
}
final Set<int> _activePointers = Set<int>();
final Set<int> _activePointers = <int>{};
void _handlePointerDown(PointerDownEvent event) {
_activePointers.add(event.pointer);

View file

@ -297,7 +297,7 @@ class _AndroidViewState extends State<AndroidView> {
bool _initialized = false;
static final Set<Factory<OneSequenceGestureRecognizer>> _emptyRecognizersSet =
Set<Factory<OneSequenceGestureRecognizer>>();
<Factory<OneSequenceGestureRecognizer>>{};
@override
Widget build(BuildContext context) {
@ -380,7 +380,7 @@ class _UiKitViewState extends State<UiKitView> {
bool _initialized = false;
static final Set<Factory<OneSequenceGestureRecognizer>> _emptyRecognizersSet =
Set<Factory<OneSequenceGestureRecognizer>>();
<Factory<OneSequenceGestureRecognizer>>{};
@override
Widget build(BuildContext context) {

View file

@ -1363,7 +1363,7 @@ class RouteObserver<R extends Route<dynamic>> extends NavigatorObserver {
void subscribe(RouteAware routeAware, R route) {
assert(routeAware != null);
assert(route != null);
final Set<RouteAware> subscribers = _listeners.putIfAbsent(route, () => Set<RouteAware>());
final Set<RouteAware> subscribers = _listeners.putIfAbsent(route, () => <RouteAware>{});
if (subscribers.add(routeAware)) {
routeAware.didPush();
}

View file

@ -432,7 +432,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
break;
}
final Set<SemanticsAction> actions = Set<SemanticsAction>();
final Set<SemanticsAction> actions = <SemanticsAction>{};
if (pixels > minScrollExtent)
actions.add(backward);
if (pixels < maxScrollExtent)

View file

@ -308,7 +308,7 @@ class _TableElement extends RenderObjectElement {
}
final Iterator<_TableElementRow> oldUnkeyedRows = _children.where((_TableElementRow row) => row.key == null).iterator;
final List<_TableElementRow> newChildren = <_TableElementRow>[];
final Set<List<Element>> taken = Set<List<Element>>();
final Set<List<Element>> taken = <List<Element>>{};
for (TableRow row in newWidget.children) {
List<Element> oldChildren;
if (row.key != null && oldKeyedRows.containsKey(row.key)) {

View file

@ -157,7 +157,7 @@ mixin TickerProviderStateMixin<T extends StatefulWidget> on State<T> implements
@override
Ticker createTicker(TickerCallback onTick) {
_tickers ??= Set<_WidgetTicker>();
_tickers ??= <_WidgetTicker>{};
final _WidgetTicker result = _WidgetTicker(onTick, this, debugLabel: 'created by $this');
_tickers.add(result);
return result;

View file

@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:developer' as developer;
import 'dart:math' as math;
@ -2259,7 +2258,7 @@ class _WidgetInspectorState extends State<WidgetInspector>
return size == null ? double.maxFinite : size.width * size.height;
}
regularHits.sort((RenderObject a, RenderObject b) => _area(a).compareTo(_area(b)));
final Set<RenderObject> hits = LinkedHashSet<RenderObject>();
final Set<RenderObject> hits = <RenderObject>{};
hits..addAll(edgeHits)..addAll(regularHits);
return hits.toList();
}

View file

@ -89,7 +89,7 @@ void main() {
expect(config.getActionHandler(SemanticsAction.scrollRight), isNotNull);
config = SemanticsConfiguration();
renderObj.validActions = <SemanticsAction>[SemanticsAction.tap, SemanticsAction.scrollLeft].toSet();
renderObj.validActions = <SemanticsAction>{SemanticsAction.tap, SemanticsAction.scrollLeft};
renderObj.describeSemanticsConfiguration(config);
expect(config.getActionHandler(SemanticsAction.tap), isNotNull);

View file

@ -26,7 +26,7 @@ void main() {
expect(node.isTagged(tag1), isFalse);
expect(node.isTagged(tag2), isFalse);
node.tags = Set<SemanticsTag>()..add(tag1);
node.tags = <SemanticsTag>{tag1};
expect(node.isTagged(tag1), isTrue);
expect(node.isTagged(tag2), isFalse);
@ -36,9 +36,7 @@ void main() {
});
test('getSemanticsData includes tags', () {
final Set<SemanticsTag> tags = Set<SemanticsTag>()
..add(tag1)
..add(tag2);
final Set<SemanticsTag> tags = <SemanticsTag>{tag1, tag2};
final SemanticsNode node = SemanticsNode()
..rect = Rect.fromLTRB(0.0, 0.0, 10.0, 10.0)

View file

@ -20,7 +20,7 @@ class FakeAndroidPlatformViewsController {
final Map<int, List<FakeAndroidMotionEvent>> motionEvents = <int, List<FakeAndroidMotionEvent>>{};
final Set<String> _registeredViewTypes = Set<String>();
final Set<String> _registeredViewTypes = <String>{};
int _textureCounter = 0;
@ -153,7 +153,7 @@ class FakeIosPlatformViewsController {
Iterable<FakeUiKitView> get views => _views.values;
final Map<int, FakeUiKitView> _views = <int, FakeUiKitView>{};
final Set<String> _registeredViewTypes = Set<String>();
final Set<String> _registeredViewTypes = <String>{};
// When this completer is non null, the 'create' method channel call will be
// delayed until it completes.

View file

@ -241,7 +241,7 @@ void main() {
child: ABCModel( // The "inner" model
a: 100 + _a,
b: 100 + _b,
aspects: Set<String>.of(<String>['a']),
aspects: <String>{'a'},
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
@ -328,7 +328,7 @@ void main() {
int _a = 0;
int _b = 1;
int _c = 2;
Set<String> _innerModelAspects = Set<String>.of(<String>['a']);
Set<String> _innerModelAspects = <String>{'a'};
// Same as in abcPage in the "Inner InheritedModel shadows the outer one"
// test except: the "Add b aspect" changes adds 'b' to the set of
@ -406,14 +406,14 @@ void main() {
},
);
_innerModelAspects = Set<String>.of(<String>['a']);
_innerModelAspects = <String>{'a'};
await tester.pumpWidget(MaterialApp(home: abcPage));
expect(find.text('a: 100 [0]'), findsOneWidget); // showA depends on the inner model
expect(find.text('b: 1 [0]'), findsOneWidget); // showB depends on the outer model
expect(find.text('c: 2 [0]'), findsOneWidget);
expect(find.text('a: 100 b: 101 c: null'), findsOneWidget); // inner model's a, b, c
_innerModelAspects = Set<String>.of(<String>['a', 'b']);
_innerModelAspects = <String>{'a', 'b'};
await tester.tap(find.text('rebuild'));
await tester.pumpAndSettle();
expect(find.text('a: 100 [1]'), findsOneWidget); // rebuilt showA still depend on the inner model
@ -448,7 +448,7 @@ void main() {
expect(find.text('c: 3 [2]'), findsOneWidget); // rebuilt showC still depends on the outer model
expect(find.text('a: 101 b: 102 c: null'), findsOneWidget);
_innerModelAspects = Set<String>.of(<String>['a', 'b', 'c']);
_innerModelAspects = <String>{'a', 'b', 'c'};
await tester.tap(find.text('rebuild'));
await tester.pumpAndSettle();
expect(find.text('a: 101 [3]'), findsOneWidget); // rebuilt showA still depend on the inner model
@ -457,7 +457,7 @@ void main() {
expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); // inner model's a, b, c
// Now the inner model supports no aspects
_innerModelAspects = Set<String>.of(<String>[]);
_innerModelAspects = <String>{};
await tester.tap(find.text('rebuild'));
await tester.pumpAndSettle();
expect(find.text('a: 1 [4]'), findsOneWidget); // rebuilt showA now depends on the outer model

View file

@ -277,7 +277,7 @@ void main() {
});
testWidgets('builder is never called twice for same index', (WidgetTester tester) async {
final Set<int> builtChildren = Set<int>();
final Set<int> builtChildren = <int>{};
final FixedExtentScrollController controller =
FixedExtentScrollController();

View file

@ -590,11 +590,11 @@ void main() {
height: 100.0,
child: AndroidView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(),
),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
),
@ -727,11 +727,11 @@ void main() {
height: 100.0,
child: AndroidView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
),
@ -760,11 +760,11 @@ void main() {
final AndroidView androidView = AndroidView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<EagerGestureRecognizer>(
() => EagerGestureRecognizer(),
),
].toSet(),
},
layoutDirection: TextDirection.ltr,
);
@ -786,9 +786,9 @@ void main() {
await tester.pumpWidget(
AndroidView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<EagerGestureRecognizer>(constructRecognizer),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
);
@ -797,9 +797,9 @@ void main() {
AndroidView(
viewType: 'webview',
hitTestBehavior: PlatformViewHitTestBehavior.translucent,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<EagerGestureRecognizer>(constructRecognizer),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
);
@ -1214,11 +1214,11 @@ void main() {
height: 100.0,
child: UiKitView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(),
),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
),
@ -1338,11 +1338,11 @@ void main() {
height: 100.0,
child: UiKitView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
),
@ -1407,9 +1407,9 @@ void main() {
await tester.pumpWidget(
UiKitView(
viewType: 'webview',
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<EagerGestureRecognizer>(constructRecognizer),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
);
@ -1418,9 +1418,9 @@ void main() {
UiKitView(
viewType: 'webview',
hitTestBehavior: PlatformViewHitTestBehavior.translucent,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<EagerGestureRecognizer>(constructRecognizer),
].toSet(),
},
layoutDirection: TextDirection.ltr,
),
);

View file

@ -61,7 +61,7 @@ class TestSemantics {
assert(decreasedValue != null),
assert(hint != null),
assert(children != null),
tags = tags?.toSet() ?? Set<SemanticsTag>();
tags = tags?.toSet() ?? <SemanticsTag>{};
/// Creates an object with some test semantics data, with the [id] and [rect]
/// set to the appropriate values for the root node.
@ -92,7 +92,7 @@ class TestSemantics {
elevation = 0.0,
thickness = 0.0,
assert(children != null),
tags = tags?.toSet() ?? Set<SemanticsTag>();
tags = tags?.toSet() ?? <SemanticsTag>{};
/// Creates an object with some test semantics data, with the [id] and [rect]
/// set to the appropriate values for direct children of the root node.
@ -131,7 +131,7 @@ class TestSemantics {
assert(hint != null),
transform = _applyRootChildScale(transform),
assert(children != null),
tags = tags?.toSet() ?? Set<SemanticsTag>();
tags = tags?.toSet() ?? <SemanticsTag>{};
/// The unique identifier for this node.
///

View file

@ -573,7 +573,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal
// Keep track of initialzed locales, or will fail on attempted double init.
// This can only happen if a locale with a stripped scriptCode has already
// been initialzed. This should be removed when scriptCode stripping is removed.
final Set<String> initializedLocales = Set<String>();
final Set<String> initializedLocales = <String>{};
date_localizations.dateSymbols.forEach((String locale, dynamic data) {
// Strip scriptCode from the locale, as we do not distinguish between scripts
// for dates.

View file

@ -365,7 +365,7 @@ class _Reporter {
String _lastProgressSuffix;
/// The set of all subscriptions to various streams.
final Set<StreamSubscription<void>> _subscriptions = Set<StreamSubscription<void>>();
final Set<StreamSubscription<void>> _subscriptions = <StreamSubscription<void>>{};
/// A callback called when the engine begins running [liveTest].
void _onTestStarted(LiveTest liveTest) {

View file

@ -551,7 +551,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
@override
Ticker createTicker(TickerCallback onTick) {
_tickers ??= Set<_TestTicker>();
_tickers ??= <_TestTicker>{};
final _TestTicker result = _TestTicker(onTick, _removeTicker);
_tickers.add(result);
return result;

View file

@ -682,7 +682,7 @@ class GradleProject {
.trim();
// Extract build types and product flavors.
final Set<String> variants = Set<String>();
final Set<String> variants = <String>{};
for (String s in tasks.split('\n')) {
final Match match = _assembleTaskPattern.matchAsPrefix(s);
if (match != null) {
@ -691,8 +691,8 @@ class GradleProject {
variants.add(variant);
}
}
final Set<String> buildTypes = Set<String>();
final Set<String> productFlavors = Set<String>();
final Set<String> buildTypes = <String>{};
final Set<String> productFlavors = <String>{};
for (final String variant1 in variants) {
for (final String variant2 in variants) {
if (variant2.startsWith(variant1) && variant2 != variant1) {

View file

@ -320,7 +320,7 @@ Future<DevFSContent> _obtainLicenses(
// example, a package might itself contain code from multiple third-party
// sources, and might need to include a license for each one.)
final Map<String, Set<String>> packageLicenses = <String, Set<String>>{};
final Set<String> allPackages = Set<String>();
final Set<String> allPackages = <String>{};
for (String packageName in packageMap.map.keys) {
final Uri package = packageMap.map[packageName];
if (package != null && package.scheme == 'file') {
@ -342,7 +342,7 @@ Future<DevFSContent> _obtainLicenses(
packageNames = <String>[packageName];
licenseText = rawLicense;
}
packageLicenses.putIfAbsent(licenseText, () => Set<String>())
packageLicenses.putIfAbsent(licenseText, () => <String>{})
..addAll(packageNames);
allPackages.addAll(packageNames);
}

View file

@ -118,7 +118,7 @@ class AOTSnapshotter {
final String vmServicePath = fs.path.join(skyEnginePkg, 'sdk_ext', 'vmservice_io.dart');
final List<String> inputPaths = <String>[uiPath, vmServicePath, mainPath];
final Set<String> outputPaths = Set<String>();
final Set<String> outputPaths = <String>{};
final String depfilePath = fs.path.join(outputDir.path, 'snapshot.d');
final List<String> genSnapshotArgs = <String>[
@ -458,7 +458,7 @@ class JITSnapshotter {
genSnapshotArgs.addAll(extraGenSnapshotOptions);
}
final Set<String> outputPaths = Set<String>();
final Set<String> outputPaths = <String>{};
outputPaths.addAll(<String>[isolateSnapshotData]);
if (!createPatch) {
outputPaths.add(isolateSnapshotInstructions);

View file

@ -146,7 +146,7 @@ String getDisplayPath(String fullPath) {
/// available.
class ItemListNotifier<T> {
ItemListNotifier() {
_items = Set<T>();
_items = <T>{};
}
ItemListNotifier.from(List<T> items) {

View file

@ -26,7 +26,7 @@ class AnalyzeContinuously extends AnalyzeBase {
String analysisTarget;
bool firstAnalysis = true;
Set<String> analyzedPaths = Set<String>();
Set<String> analyzedPaths = <String>{};
Map<String, List<AnalysisError>> analysisErrors = <String, List<AnalysisError>>{};
Stopwatch analysisTimer;
int lastErrorCount = 0;

View file

@ -52,7 +52,7 @@ class ChannelCommand extends FlutterCommand {
// Beware: currentBranch could contain PII. See getBranchName().
final String currentChannel = FlutterVersion.instance.channel;
final String currentBranch = FlutterVersion.instance.getBranchName();
final Set<String> seenChannels = Set<String>();
final Set<String> seenChannels = <String>{};
final List<String> rawOutput = <String>[];
showAll = showAll || currentChannel != currentBranch;

View file

@ -612,7 +612,7 @@ String _createUTIIdentifier(String organization, String name) {
return segments.join('.');
}
final Set<String> _packageDependencies = Set<String>.from(<String>[
const Set<String> _packageDependencies = <String>{
'analyzer',
'args',
'async',
@ -639,7 +639,7 @@ final Set<String> _packageDependencies = Set<String>.from(<String>[
'utf',
'watcher',
'yaml',
]);
};
/// Return null if the project name is legal. Return a validation message if
/// we should disallow the project name.

View file

@ -121,7 +121,7 @@ class IdeConfigCommand extends FlutterCommand {
return;
}
final Set<String> manifest = Set<String>();
final Set<String> manifest = <String>{};
final List<FileSystemEntity> flutterFiles = _flutterRoot.listSync(recursive: true);
for (FileSystemEntity entity in flutterFiles) {
final String relativePath = fs.path.relative(entity.path, from: _flutterRoot.absolute.path);

View file

@ -200,7 +200,7 @@ class UpdatePackagesCommand extends FlutterCommand {
// First, collect up the explicit dependencies:
final List<PubspecYaml> pubspecs = <PubspecYaml>[];
final Map<String, PubspecDependency> dependencies = <String, PubspecDependency>{};
final Set<String> specialDependencies = Set<String>();
final Set<String> specialDependencies = <String>{};
for (Directory directory in packages) { // these are all the directories with pubspec.yamls we care about
printTrace('Reading pubspec.yaml from: ${directory.path}');
PubspecYaml pubspec;
@ -279,7 +279,7 @@ class UpdatePackagesCommand extends FlutterCommand {
for (PubspecDependency dependency in pubspec.dependencies) {
if (dependency.kind == DependencyKind.normal) {
tree._versions[package] = version;
tree._dependencyTree[package] ??= Set<String>();
tree._dependencyTree[package] ??= <String>{};
tree._dependencyTree[package].add(dependency.name);
}
}
@ -341,7 +341,7 @@ class UpdatePackagesCommand extends FlutterCommand {
throwToolExit('Package $to not found in the dependency tree.');
final Queue<_DependencyLink> traversalQueue = Queue<_DependencyLink>();
final Set<String> visited = Set<String>();
final Set<String> visited = <String>{};
final List<_DependencyLink> paths = <_DependencyLink>[];
traversalQueue.addFirst(_DependencyLink(from: null, to: from));
@ -625,8 +625,8 @@ class PubspecYaml {
void apply(PubDependencyTree versions, Set<String> specialDependencies) {
assert(versions != null);
final List<String> output = <String>[]; // the string data to output to the file, line by line
final Set<String> directDependencies = Set<String>(); // packages this pubspec directly depends on (i.e. not transitive)
final Set<String> devDependencies = Set<String>();
final Set<String> directDependencies = <String>{}; // packages this pubspec directly depends on (i.e. not transitive)
final Set<String> devDependencies = <String>{};
Section section = Section.other; // the section we're currently handling
// the line number where we're going to insert the transitive dependencies.
@ -723,8 +723,8 @@ class PubspecYaml {
final List<String> transitiveDevDependencyOutput = <String>[];
// Which dependencies we need to handle for the transitive and dev dependency sections.
final Set<String> transitiveDependencies = Set<String>();
final Set<String> transitiveDevDependencies = Set<String>();
final Set<String> transitiveDependencies = <String>{};
final Set<String> transitiveDevDependencies = <String>{};
// Merge the lists of dependencies we've seen in this file from dependencies, dev dependencies,
// and the dependencies we know this file mentions that are already pinned
@ -735,7 +735,7 @@ class PubspecYaml {
// Create a new set to hold the list of packages we've already processed, so
// that we don't redundantly process them multiple times.
final Set<String> done = Set<String>();
final Set<String> done = <String>{};
for (String package in directDependencies)
transitiveDependencies.addAll(versions.getTransitiveDependenciesFor(package, seen: done, exclude: implied));
for (String package in devDependencies)
@ -752,7 +752,7 @@ class PubspecYaml {
transitiveDevDependencyOutput.add(' $package: ${versions.versionFor(package)} $kTransitiveMagicString');
// Build a sorted list of all dependencies for the checksum.
final Set<String> checksumDependencies = Set<String>()
final Set<String> checksumDependencies = <String>{}
..addAll(directDependencies)
..addAll(devDependencies)
..addAll(transitiveDependenciesAsList)

View file

@ -11,7 +11,7 @@ class DependencyChecker {
DependencyChecker(this.builder, this.assets);
final DartDependencySetBuilder builder;
final Set<String> _dependencies = Set<String>();
final Set<String> _dependencies = <String>{};
final AssetBundle assets;
/// Returns [true] if any components have been modified after [threshold] or

View file

@ -403,7 +403,7 @@ class DevFS {
final Directory rootDirectory;
String _packagesFilePath;
final Map<Uri, DevFSContent> _entries = <Uri, DevFSContent>{};
final Set<String> assetPathsToEvict = Set<String>();
final Set<String> assetPathsToEvict = <String>{};
final List<Future<Map<String, dynamic>>> _pendingOperations =
<Future<Map<String, dynamic>>>[];
@ -533,7 +533,7 @@ class DevFS {
// run with no changes is supposed to be fast (considering that it is
// initiated by user key press).
final List<String> invalidatedFiles = <String>[];
final Set<Uri> filesUris = Set<Uri>();
final Set<Uri> filesUris = <Uri>{};
for (Uri uri in dirtyEntries.keys.toList()) {
if (!uri.path.startsWith(assetBuildDirPrefix)) {
final DevFSContent content = dirtyEntries[uri];

View file

@ -391,9 +391,9 @@ void _validateFonts(YamlList fonts, List<String> errors) {
if (fonts == null) {
return;
}
final Set<int> fontWeights = Set<int>.from(const <int>[
const Set<int> fontWeights = <int>{
100, 200, 300, 400, 500, 600, 700, 800, 900,
]);
};
for (final YamlMap fontMap in fonts) {
for (dynamic key in fontMap.keys.where((dynamic key) => key != 'family' && key != 'fonts')) {
errors.add('Unexpected child "$key" found under "fonts".');

View file

@ -733,7 +733,7 @@ Future<bool> upgradePbxProjWithFlutterAssets(IosProject project) async {
final RegExp oldAssets = RegExp(r'\/\* (flutter_assets|app\.flx)');
final StringBuffer buffer = StringBuffer();
final Set<String> printedStatuses = Set<String>();
final Set<String> printedStatuses = <String>{};
for (final String line in lines) {
final Match match = oldAssets.firstMatch(line);

View file

@ -43,12 +43,12 @@ class FlutterVersion {
String _repositoryUrl;
String get repositoryUrl => _repositoryUrl;
static Set<String> officialChannels = Set<String>.from(<String>[
static const Set<String> officialChannels = <String>{
'master',
'dev',
'beta',
'stable',
]);
};
/// This maps old branch names to the names of branches that replaced them.
///

View file

@ -272,7 +272,7 @@ class VMService {
final Map<String, StreamController<ServiceEvent>> _eventControllers =
<String, StreamController<ServiceEvent>>{};
final Set<String> _listeningFor = Set<String>();
final Set<String> _listeningFor = <String>{};
/// Whether our connection to the VM service has been closed;
bool get isClosed => _peer.isClosed;
@ -749,7 +749,7 @@ class VM extends ServiceObjectOwner {
void _removeDeadIsolates(List<Isolate> newIsolates) {
// Build a set of new isolates.
final Set<String> newIsolateSet = Set<String>();
final Set<String> newIsolateSet = <String>{};
for (Isolate iso in newIsolates)
newIsolateSet.add(iso.id);

View file

@ -300,7 +300,7 @@ void main() {
const String packageName = 'doubleslashpkg';
await _createPackage(fs, packageName, 'somefile.txt', doubleSlash: true);
final Set<String> fileFilter = Set<String>();
final Set<String> fileFilter = <String>{};
final List<Uri> pkgUris = <Uri>[fs.path.toUri(basePath)]..addAll(_packages.values);
for (Uri pkgUri in pkgUris) {
if (!pkgUri.isAbsolute) {

View file

@ -114,7 +114,7 @@ void main() {
pathToReload: anyNamed('pathToReload'),
)).thenAnswer((Invocation _) => Future<UpdateFSReport>.value(
UpdateFSReport(success: true, syncedBytes: 1000, invalidatedSourcesCount: 1)));
when(mockDevFs.assetPathsToEvict).thenReturn(Set<String>());
when(mockDevFs.assetPathsToEvict).thenReturn(<String>{});
when(mockDevFs.baseUri).thenReturn(Uri.file('test'));
setUp(() {

View file

@ -62,7 +62,7 @@ baz=qux
});
test('is pretty random', () {
final Set<String> set = Set<String>();
final Set<String> set = <String>{};
Uuid uuid = Uuid();
for (int i = 0; i < 64; i++) {

View file

@ -117,7 +117,7 @@ class FuchsiaRemoteConnection {
final Map<int, PortForwarder> _dartVmPortMap = <int, PortForwarder>{};
/// Tracks stale ports so as not to reconnect while polling.
final Set<int> _stalePorts = Set<int>();
final Set<int> _stalePorts = <int>{};
/// A broadcast stream that emits events relating to Dart VM's as they update.
Stream<DartVmEvent> get onDartVmEvent => _onDartVmEvent;