Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -10,17 +10,17 @@ void main() {
testWidgets('What should be visible in the initial state.', (WidgetTester tester) async {
await tester.pumpWidget(const example.CustomScrollViewExampleApp());
expect(find.descendant(
of: find.byType(IconButton),
matching: find.byIcon(Icons.add),
), findsOne);
expect(
find.descendant(of: find.byType(IconButton), matching: find.byIcon(Icons.add)),
findsOne,
);
expect(find.byType(SliverList), findsOne);
// Initial state should present only "Item: 0" on the SliverList.
expect(find.widgetWithText(SliverList, 'Item: 0'), findsOne);
expect(find.widgetWithText(SliverList, 'Item: -1'), findsNothing);
expect(find.widgetWithText(SliverList, 'Item: 1'), findsNothing);
});
});
testWidgets('Items are added correctly', (WidgetTester tester) async {
await tester.pumpWidget(const example.CustomScrollViewExampleApp());

View File

@@ -13,13 +13,36 @@ void main() {
fullRowPeriod: 3,
dimension: 100,
);
final List<double> scrollOffsets = List<double>.generate(10, (int i) => layout.computeMaxScrollOffset(i));
expect(scrollOffsets, <double>[0.0, 0.0, 100.0, 100.0, 200.0, 300.0, 300.0, 400.0, 400.0, 500.0]);
final List<int> minOffsets = List<int>.generate(10, (int i) => layout.getMinChildIndexForScrollOffset(i * 80.0));
final List<double> scrollOffsets = List<double>.generate(
10,
(int i) => layout.computeMaxScrollOffset(i),
);
expect(scrollOffsets, <double>[
0.0,
0.0,
100.0,
100.0,
200.0,
300.0,
300.0,
400.0,
400.0,
500.0,
]);
final List<int> minOffsets = List<int>.generate(
10,
(int i) => layout.getMinChildIndexForScrollOffset(i * 80.0),
);
expect(minOffsets, <int>[0, 0, 2, 4, 5, 7, 7, 9, 10, 12]);
final List<int> maxOffsets = List<int>.generate(10, (int i) => layout.getMaxChildIndexForScrollOffset(i * 80.0));
final List<int> maxOffsets = List<int>.generate(
10,
(int i) => layout.getMaxChildIndexForScrollOffset(i * 80.0),
);
expect(maxOffsets, <double>[1, 1, 3, 4, 6, 8, 8, 9, 11, 13]);
final List<SliverGridGeometry> offsets = List<SliverGridGeometry>.generate(20, (int i) => layout.getGeometryForChildIndex(i));
final List<SliverGridGeometry> offsets = List<SliverGridGeometry>.generate(
20,
(int i) => layout.getGeometryForChildIndex(i),
);
offsets.reduce((SliverGridGeometry a, SliverGridGeometry b) {
if (a.scrollOffset == b.scrollOffset) {
expect(a.crossAxisOffset, lessThan(b.crossAxisOffset));

View File

@@ -3,16 +3,12 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/scroll_view/list_view.0.dart'
as example;
import 'package:flutter_api_samples/widgets/scroll_view/list_view.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('long press ListTile should enable edit mode',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.ListViewExampleApp(),
);
testWidgets('long press ListTile should enable edit mode', (WidgetTester tester) async {
await tester.pumpWidget(const example.ListViewExampleApp());
final Finder listView = find.byType(ListView);
final Finder selectAllFinder = find.text('select all');
@@ -26,11 +22,8 @@ void main() {
expect(checkBoxFinder, findsWidgets);
});
testWidgets('Pressing cross button should disable edit mode',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.ListViewExampleApp(),
);
testWidgets('Pressing cross button should disable edit mode', (WidgetTester tester) async {
await tester.pumpWidget(const example.ListViewExampleApp());
final Finder listView = find.byType(ListView);
final Finder crossIconFinder = find.byIcon(Icons.close);
@@ -49,11 +42,10 @@ void main() {
expect(crossIconFinder, findsNothing);
});
testWidgets('tapping ListTile or checkBox should toggle ListTile state',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.ListViewExampleApp(),
);
testWidgets('tapping ListTile or checkBox should toggle ListTile state', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.ListViewExampleApp());
final Finder listView = find.byType(ListView);
final Finder selectAllFinder = find.text('select all');

View File

@@ -3,26 +3,22 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/scroll_view/list_view.1.dart'
as example;
import 'package:flutter_api_samples/widgets/scroll_view/list_view.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'tapping Reverse button should reverse ListView',
(WidgetTester tester) async {
await tester.pumpWidget(const example.ListViewExampleApp());
final Finder listView = find.byType(ListView);
final Finder reverseFinder = find.text('Reverse items');
expect(listView, findsOneWidget);
expect(reverseFinder, findsOneWidget);
final Finder keepAliveItemFinder = find.byType(example.KeepAliveItem);
example.KeepAliveItem firstWidget = tester.firstWidget(keepAliveItemFinder);
expect(firstWidget.data, '1');
await tester.tap(reverseFinder);
await tester.pump();
firstWidget = tester.firstWidget(keepAliveItemFinder);
expect(firstWidget.data, '5');
},
);
testWidgets('tapping Reverse button should reverse ListView', (WidgetTester tester) async {
await tester.pumpWidget(const example.ListViewExampleApp());
final Finder listView = find.byType(ListView);
final Finder reverseFinder = find.text('Reverse items');
expect(listView, findsOneWidget);
expect(reverseFinder, findsOneWidget);
final Finder keepAliveItemFinder = find.byType(example.KeepAliveItem);
example.KeepAliveItem firstWidget = tester.firstWidget(keepAliveItemFinder);
expect(firstWidget.data, '1');
await tester.tap(reverseFinder);
await tester.pump();
firstWidget = tester.firstWidget(keepAliveItemFinder);
expect(firstWidget.data, '5');
});
}