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

@@ -5,58 +5,42 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_api_samples/material/selection_container/selection_container.0.dart' as example;
import 'package:flutter_api_samples/material/selection_container/selection_container.0.dart'
as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('The SelectionContainer should transform the partial selection into an all selection', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SelectionContainerExampleApp(),
);
testWidgets(
'The SelectionContainer should transform the partial selection into an all selection',
(WidgetTester tester) async {
await tester.pumpWidget(const example.SelectionContainerExampleApp());
expect(find.widgetWithText(AppBar, 'SelectionContainer Sample'), findsOne);
expect(find.widgetWithText(AppBar, 'SelectionContainer Sample'), findsOne);
final RenderParagraph paragraph1 = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.text('Row 1'),
matching: find.byType(RichText),
),
);
final RenderParagraph paragraph2 = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.text('Row 2'),
matching: find.byType(RichText),
),
);
final RenderParagraph paragraph3 = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.text('Row 3'),
matching: find.byType(RichText),
),
);
final Rect paragraph1Rect = tester.getRect(find.text('Row 1'));
final TestGesture gesture = await tester.startGesture(
paragraph1Rect.topLeft,
kind: PointerDeviceKind.mouse,
);
addTearDown(gesture.removePointer);
await tester.pump();
final RenderParagraph paragraph1 = tester.renderObject<RenderParagraph>(
find.descendant(of: find.text('Row 1'), matching: find.byType(RichText)),
);
final RenderParagraph paragraph2 = tester.renderObject<RenderParagraph>(
find.descendant(of: find.text('Row 2'), matching: find.byType(RichText)),
);
final RenderParagraph paragraph3 = tester.renderObject<RenderParagraph>(
find.descendant(of: find.text('Row 3'), matching: find.byType(RichText)),
);
final Rect paragraph1Rect = tester.getRect(find.text('Row 1'));
final TestGesture gesture = await tester.startGesture(
paragraph1Rect.topLeft,
kind: PointerDeviceKind.mouse,
);
addTearDown(gesture.removePointer);
await tester.pump();
await gesture.moveTo(paragraph1Rect.center);
await tester.pump();
expect(
paragraph1.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 5),
);
expect(
paragraph2.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 5),
);
expect(
paragraph3.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 5),
);
await gesture.moveTo(paragraph1Rect.center);
await tester.pump();
expect(paragraph1.selections.first, const TextSelection(baseOffset: 0, extentOffset: 5));
expect(paragraph2.selections.first, const TextSelection(baseOffset: 0, extentOffset: 5));
expect(paragraph3.selections.first, const TextSelection(baseOffset: 0, extentOffset: 5));
await gesture.up();
});
await gesture.up();
},
);
}

View File

@@ -5,22 +5,20 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_api_samples/material/selection_container/selection_container_disabled.0.dart' as example;
import 'package:flutter_api_samples/material/selection_container/selection_container_disabled.0.dart'
as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('A SelectionContainer.disabled should disable selections', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SelectionContainerDisabledExampleApp(),
);
testWidgets('A SelectionContainer.disabled should disable selections', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.SelectionContainerDisabledExampleApp());
expect(find.widgetWithText(AppBar, 'SelectionContainer.disabled Sample'), findsOne);
final RenderParagraph paragraph1 = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.text('Selectable text').first,
matching: find.byType(RichText),
),
find.descendant(of: find.text('Selectable text').first, matching: find.byType(RichText)),
);
final Rect paragraph1Rect = tester.getRect(find.text('Selectable text').first);
final TestGesture gesture = await tester.startGesture(
@@ -32,44 +30,26 @@ void main() {
await gesture.moveTo(paragraph1Rect.center);
await tester.pump();
expect(
paragraph1.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 7),
);
expect(paragraph1.selections.first, const TextSelection(baseOffset: 0, extentOffset: 7));
final RenderParagraph paragraph2 = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.text('Non-selectable text'),
matching: find.byType(RichText),
),
find.descendant(of: find.text('Non-selectable text'), matching: find.byType(RichText)),
);
final Rect paragraph2Rect = tester.getRect(find.text('Non-selectable text'));
await gesture.moveTo(paragraph2Rect.center);
// Should select the rest of paragraph 1.
expect(
paragraph1.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 15),
);
expect(paragraph1.selections.first, const TextSelection(baseOffset: 0, extentOffset: 15));
// paragraph2 is in a disabled container.
expect(paragraph2.selections, isEmpty);
final RenderParagraph paragraph3 = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.text('Selectable text').last,
matching: find.byType(RichText),
),
find.descendant(of: find.text('Selectable text').last, matching: find.byType(RichText)),
);
final Rect paragraph3Rect = tester.getRect(find.text('Selectable text').last);
await gesture.moveTo(paragraph3Rect.center);
expect(
paragraph1.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 15),
);
expect(paragraph1.selections.first, const TextSelection(baseOffset: 0, extentOffset: 15));
expect(paragraph2.selections, isEmpty);
expect(
paragraph3.selections.first,
const TextSelection(baseOffset: 0, extentOffset: 7),
);
expect(paragraph3.selections.first, const TextSelection(baseOffset: 0, extentOffset: 7));
await gesture.up();
});