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

@@ -48,28 +48,19 @@ class MySelectableAdapter extends StatelessWidget {
}
return MouseRegion(
cursor: SystemMouseCursors.text,
child: _SelectableAdapter(
registrar: registrar,
child: child,
),
child: _SelectableAdapter(registrar: registrar, child: child),
);
}
}
class _SelectableAdapter extends SingleChildRenderObjectWidget {
const _SelectableAdapter({
required this.registrar,
required Widget child,
}) : super(child: child);
const _SelectableAdapter({required this.registrar, required Widget child}) : super(child: child);
final SelectionRegistrar registrar;
@override
_RenderSelectableAdapter createRenderObject(BuildContext context) {
return _RenderSelectableAdapter(
DefaultSelectionStyle.of(context).selectionColor!,
registrar,
);
return _RenderSelectableAdapter(DefaultSelectionStyle.of(context).selectionColor!, registrar);
}
@override
@@ -81,16 +72,17 @@ class _SelectableAdapter extends SingleChildRenderObjectWidget {
}
class _RenderSelectableAdapter extends RenderProxyBox with Selectable, SelectionRegistrant {
_RenderSelectableAdapter(
Color selectionColor,
SelectionRegistrar registrar,
) : _selectionColor = selectionColor,
_geometry = ValueNotifier<SelectionGeometry>(_noSelection) {
_RenderSelectableAdapter(Color selectionColor, SelectionRegistrar registrar)
: _selectionColor = selectionColor,
_geometry = ValueNotifier<SelectionGeometry>(_noSelection) {
this.registrar = registrar;
_geometry.addListener(markNeedsPaint);
}
static const SelectionGeometry _noSelection = SelectionGeometry(status: SelectionStatus.none, hasContent: true);
static const SelectionGeometry _noSelection = SelectionGeometry(
status: SelectionStatus.none,
hasContent: true,
);
final ValueNotifier<SelectionGeometry> _geometry;
Color get selectionColor => _selectionColor;
@@ -122,7 +114,12 @@ class _RenderSelectableAdapter extends RenderProxyBox with Selectable, Selection
// Adjust this value to enlarge or shrink the selection highlight.
static const double _padding = 10.0;
Rect _getSelectionHighlightRect() {
return Rect.fromLTWH(0 - _padding, 0 - _padding, size.width + _padding * 2, size.height + _padding * 2);
return Rect.fromLTWH(
0 - _padding,
0 - _padding,
size.width + _padding * 2,
size.height + _padding * 2,
);
}
Offset? _start;
@@ -191,7 +188,8 @@ class _RenderSelectableAdapter extends RenderProxyBox with Selectable, Selection
_end = Offset.infinite;
case SelectionEventType.granularlyExtendSelection:
result = SelectionResult.end;
final GranularlyExtendSelectionEvent extendSelectionEvent = event as GranularlyExtendSelectionEvent;
final GranularlyExtendSelectionEvent extendSelectionEvent =
event as GranularlyExtendSelectionEvent;
// Initialize the offset it there is no ongoing selection.
if (_start == null || _end == null) {
if (extendSelectionEvent.forward) {
@@ -215,7 +213,8 @@ class _RenderSelectableAdapter extends RenderProxyBox with Selectable, Selection
}
case SelectionEventType.directionallyExtendSelection:
result = SelectionResult.end;
final DirectionallyExtendSelectionEvent extendSelectionEvent = event as DirectionallyExtendSelectionEvent;
final DirectionallyExtendSelectionEvent extendSelectionEvent =
event as DirectionallyExtendSelectionEvent;
// Convert to local coordinates.
final double horizontalBaseLine = globalToLocal(Offset(event.dx, 0)).dx;
final Offset newOffset;
@@ -229,7 +228,8 @@ class _RenderSelectableAdapter extends RenderProxyBox with Selectable, Selection
_start = _end = Offset.infinite;
}
// Move the corresponding selection edge.
if (extendSelectionEvent.direction == SelectionExtendDirection.previousLine || horizontalBaseLine < 0) {
if (extendSelectionEvent.direction == SelectionExtendDirection.previousLine ||
horizontalBaseLine < 0) {
newOffset = Offset.zero;
} else {
newOffset = Offset.infinite;
@@ -277,10 +277,7 @@ class _RenderSelectableAdapter extends RenderProxyBox with Selectable, Selection
if (!value.hasSelection) {
return null;
}
return const SelectedContentRange(
startOffset: 0,
endOffset: 1,
);
return const SelectedContentRange(startOffset: 0, endOffset: 1);
}
@override
@@ -306,28 +303,23 @@ class _RenderSelectableAdapter extends RenderProxyBox with Selectable, Selection
return;
}
// Draw the selection highlight.
final Paint selectionPaint = Paint()
..style = PaintingStyle.fill
..color = _selectionColor;
final Paint selectionPaint =
Paint()
..style = PaintingStyle.fill
..color = _selectionColor;
context.canvas.drawRect(_getSelectionHighlightRect().shift(offset), selectionPaint);
// Push the layer links if any.
if (_startHandle != null) {
context.pushLayer(
LeaderLayer(
link: _startHandle!,
offset: offset + value.startSelectionPoint!.localPosition,
),
LeaderLayer(link: _startHandle!, offset: offset + value.startSelectionPoint!.localPosition),
(PaintingContext context, Offset offset) {},
Offset.zero,
);
}
if (_endHandle != null) {
context.pushLayer(
LeaderLayer(
link: _endHandle!,
offset: offset + value.endSelectionPoint!.localPosition,
),
LeaderLayer(link: _endHandle!, offset: offset + value.endSelectionPoint!.localPosition),
(PaintingContext context, Offset offset) {},
Offset.zero,
);