enable lint prefer_final_in_for_each (#47724)
This commit is contained in:
committed by
GitHub
parent
fa337f5922
commit
4f9b6cf017
@@ -158,14 +158,14 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (NavigationIconView view in _navigationViews)
|
||||
for (final NavigationIconView view in _navigationViews)
|
||||
view.controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _buildTransitionsStack() {
|
||||
final List<FadeTransition> transitions = <FadeTransition>[
|
||||
for (NavigationIconView view in _navigationViews) view.transition(_type, context),
|
||||
for (final NavigationIconView view in _navigationViews) view.transition(_type, context),
|
||||
];
|
||||
|
||||
// We want to have the newly animating (fading in) views on top.
|
||||
|
||||
@@ -260,7 +260,7 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
|
||||
Set<String> allowedActions = <String>{};
|
||||
if (_selectedMaterial != null && _selectedMaterial.isNotEmpty) {
|
||||
for (String tool in _selectedTools) {
|
||||
for (final String tool in _selectedTools) {
|
||||
allowedActions.addAll(_toolActions[tool]);
|
||||
}
|
||||
allowedActions = allowedActions.intersection(_materialActions[_selectedMaterial]);
|
||||
|
||||
@@ -135,7 +135,7 @@ class DessertDataSource extends DataTableSource {
|
||||
int get selectedRowCount => _selectedCount;
|
||||
|
||||
void _selectAll(bool checked) {
|
||||
for (Dessert dessert in _desserts)
|
||||
for (final Dessert dessert in _desserts)
|
||||
dessert.selected = checked;
|
||||
_selectedCount = checked ? _desserts.length : 0;
|
||||
notifyListeners();
|
||||
|
||||
@@ -476,7 +476,7 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int product in difference) {
|
||||
for (final int product in difference) {
|
||||
if (_internalList.length < _list.length) {
|
||||
_list.remove(product);
|
||||
} else if (_internalList.length > _list.length) {
|
||||
|
||||
@@ -294,8 +294,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
|
||||
final Connectivity connectivity = Connectivity();
|
||||
ConnectivityResult previousResult = await connectivity.checkConnectivity();
|
||||
yield previousResult;
|
||||
await for (ConnectivityResult result
|
||||
in connectivity.onConnectivityChanged) {
|
||||
await for (final ConnectivityResult result in connectivity.onConnectivityChanged) {
|
||||
if (result != previousResult) {
|
||||
yield result;
|
||||
previousResult = result;
|
||||
|
||||
@@ -27,7 +27,7 @@ Future<void> _parseExampleCode(AssetBundle bundle) async {
|
||||
List<String> codeBlock;
|
||||
String codeTag;
|
||||
|
||||
for (String line in lines) {
|
||||
for (final String line in lines) {
|
||||
if (codeBlock == null) {
|
||||
// Outside a block.
|
||||
if (line.startsWith(_kStartTag)) {
|
||||
|
||||
@@ -94,7 +94,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
final List<TextSpan> formattedText = <TextSpan>[];
|
||||
int currentPosition = 0;
|
||||
|
||||
for (_HighlightSpan span in _spans) {
|
||||
for (final _HighlightSpan span in _spans) {
|
||||
if (currentPosition != span.start)
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@ Future<void> main() async {
|
||||
print('Starting app...');
|
||||
runApp(const GalleryApp(testMode: true));
|
||||
final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance);
|
||||
for (GalleryDemoCategory category in kAllGalleryDemoCategories) {
|
||||
for (final GalleryDemoCategory category in kAllGalleryDemoCategories) {
|
||||
print('Tapping "${category.name}" section...');
|
||||
await controller.tap(find.text(category.name));
|
||||
for (GalleryDemo demo in kGalleryCategoryToDemos[category]) {
|
||||
for (final GalleryDemo demo in kGalleryCategoryToDemos[category]) {
|
||||
final Finder demoItem = find.text(demo.title);
|
||||
print('Scrolling to "${demo.title}"...');
|
||||
await controller.scrollIntoView(demoItem, alignment: 0.5);
|
||||
|
||||
@@ -42,7 +42,7 @@ void verifyToStringOutput(String name, String route, String testString) {
|
||||
final List<String> lines = testString.split('\n');
|
||||
if (!testString.endsWith('\n'))
|
||||
reportToStringError(name, route, lines.length, lines, 'does not end with a line feed');
|
||||
for (String line in lines) {
|
||||
for (final String line in lines) {
|
||||
lineNumber += 1;
|
||||
if (line == '' && lineNumber != lines.length) {
|
||||
reportToStringError(name, route, lineNumber, lines, 'found empty line');
|
||||
@@ -157,11 +157,11 @@ Future<void> smokeGallery(WidgetTester tester) async {
|
||||
|
||||
expect(find.text(kGalleryTitle), findsOneWidget);
|
||||
|
||||
for (GalleryDemoCategory category in kAllGalleryDemoCategories) {
|
||||
for (final GalleryDemoCategory category in kAllGalleryDemoCategories) {
|
||||
await Scrollable.ensureVisible(tester.element(find.text(category.name)), alignment: 0.5);
|
||||
await tester.tap(find.text(category.name));
|
||||
await tester.pumpAndSettle();
|
||||
for (GalleryDemo demo in kGalleryCategoryToDemos[category]) {
|
||||
for (final GalleryDemo demo in kGalleryCategoryToDemos[category]) {
|
||||
await Scrollable.ensureVisible(tester.element(find.text(demo.title)), alignment: 0.0);
|
||||
await smokeDemo(tester, demo);
|
||||
tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after running $demo');
|
||||
|
||||
@@ -69,7 +69,7 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
|
||||
int frameStart;
|
||||
|
||||
// Save the duration of the first frame after each 'Start Transition' event.
|
||||
for (Map<String, dynamic> event in events) {
|
||||
for (final Map<String, dynamic> event in events) {
|
||||
final String eventName = event['name'] as String;
|
||||
if (eventName == 'Start Transition') {
|
||||
assert(startEvent == null);
|
||||
@@ -143,7 +143,7 @@ Future<void> runDemos(List<String> demos, FlutterDriver driver) async {
|
||||
final SerializableFinder demoList = find.byValueKey('GalleryDemoList');
|
||||
String currentDemoCategory;
|
||||
|
||||
for (String demo in demos) {
|
||||
for (final String demo in demos) {
|
||||
if (kSkippedDemos.contains(demo))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user