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:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -54,7 +54,7 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
|
||||
// Shifts the coordinate space of and rotates the current transform.
|
||||
canvas.translate(mid.dx, mid.dy);
|
||||
canvas.rotate(math.pi/4);
|
||||
canvas.rotate(math.pi / 4);
|
||||
|
||||
final ui.Gradient yellowBlue = ui.Gradient.linear(
|
||||
ui.Offset(-radius, -radius),
|
||||
@@ -73,10 +73,22 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
|
||||
// Scale x and y by 0.5.
|
||||
final Float64List scaleMatrix = Float64List.fromList(<double>[
|
||||
0.5, 0.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
]);
|
||||
canvas.transform(scaleMatrix);
|
||||
|
||||
@@ -105,15 +117,17 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = view.devicePixelRatio;
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
final Float64List deviceTransform =
|
||||
Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder =
|
||||
ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,27 +16,30 @@ void beginFrame(Duration timeStamp) {
|
||||
|
||||
final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(
|
||||
ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
)
|
||||
..addText('Hello, world.');
|
||||
final ui.Paragraph paragraph = paragraphBuilder.build()
|
||||
..layout(ui.ParagraphConstraints(width: logicalSize.width));
|
||||
)..addText('Hello, world.');
|
||||
final ui.Paragraph paragraph =
|
||||
paragraphBuilder.build()..layout(ui.ParagraphConstraints(width: logicalSize.width));
|
||||
|
||||
final ui.Rect physicalBounds = ui.Offset.zero & (logicalSize * devicePixelRatio);
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder, physicalBounds);
|
||||
canvas.scale(devicePixelRatio, devicePixelRatio);
|
||||
canvas.drawParagraph(paragraph, ui.Offset(
|
||||
(logicalSize.width - paragraph.maxIntrinsicWidth) / 2.0,
|
||||
(logicalSize.height - paragraph.height) / 2.0,
|
||||
));
|
||||
canvas.drawParagraph(
|
||||
paragraph,
|
||||
ui.Offset(
|
||||
(logicalSize.width - paragraph.maxIntrinsicWidth) / 2.0,
|
||||
(logicalSize.height - paragraph.height) / 2.0,
|
||||
),
|
||||
);
|
||||
final ui.Picture picture = recorder.endRecording();
|
||||
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
// TODO(abarth): We should be able to add a picture without pushing a
|
||||
// container layer first.
|
||||
..pushClipRect(physicalBounds)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
final ui.SceneBuilder sceneBuilder =
|
||||
ui.SceneBuilder()
|
||||
// TODO(abarth): We should be able to add a picture without pushing a
|
||||
// container layer first.
|
||||
..pushClipRect(physicalBounds)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
|
||||
view.render(sceneBuilder.build());
|
||||
}
|
||||
|
||||
@@ -41,15 +41,17 @@ void beginFrame(Duration timeStamp) {
|
||||
// COMPOSITE
|
||||
|
||||
final double devicePixelRatio = view.devicePixelRatio;
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
final Float64List deviceTransform =
|
||||
Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder =
|
||||
ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
view.render(sceneBuilder.build());
|
||||
|
||||
// After rendering the current frame of the animation, we ask the engine to
|
||||
|
||||
@@ -29,22 +29,27 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
|
||||
// The paint method of Paragraph draws the contents of the paragraph onto the
|
||||
// given canvas.
|
||||
canvas.drawParagraph(paragraph, ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0));
|
||||
canvas.drawParagraph(
|
||||
paragraph,
|
||||
ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0),
|
||||
);
|
||||
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = view.devicePixelRatio;
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
final Float64List deviceTransform =
|
||||
Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder =
|
||||
ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
@@ -61,42 +66,44 @@ void main() {
|
||||
view = ui.PlatformDispatcher.instance.implicitView!;
|
||||
|
||||
// To create a paragraph of text, we use ParagraphBuilder.
|
||||
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(
|
||||
// The text below has a primary direction of left-to-right.
|
||||
// The embedded text has other directions.
|
||||
// If this was TextDirection.rtl, the "Hello, world" text would end up on
|
||||
// the other side of the right-to-left text.
|
||||
ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
)
|
||||
// We first push a style that turns the text blue.
|
||||
..pushStyle(ui.TextStyle(color: const ui.Color(0xFF0000FF)))
|
||||
..addText('Hello, ')
|
||||
// The next run of text will be bold.
|
||||
..pushStyle(ui.TextStyle(fontWeight: ui.FontWeight.bold))
|
||||
..addText('world. ')
|
||||
// The pop() command signals the end of the bold styling.
|
||||
..pop()
|
||||
// We add text to the paragraph in logical order. The paragraph object
|
||||
// understands bi-directional text and will compute the visual ordering
|
||||
// during layout.
|
||||
..addText('هذا هو قليلا طويلة من النص الذي يجب التفاف .')
|
||||
// The second pop() removes the blue color.
|
||||
..pop()
|
||||
// We can add more text with the default styling.
|
||||
..addText(' و أكثر قليلا لجعله أطول. ')
|
||||
..addText('สวัสดี');
|
||||
final ui.ParagraphBuilder builder =
|
||||
ui.ParagraphBuilder(
|
||||
// The text below has a primary direction of left-to-right.
|
||||
// The embedded text has other directions.
|
||||
// If this was TextDirection.rtl, the "Hello, world" text would end up on
|
||||
// the other side of the right-to-left text.
|
||||
ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
)
|
||||
// We first push a style that turns the text blue.
|
||||
..pushStyle(ui.TextStyle(color: const ui.Color(0xFF0000FF)))
|
||||
..addText('Hello, ')
|
||||
// The next run of text will be bold.
|
||||
..pushStyle(ui.TextStyle(fontWeight: ui.FontWeight.bold))
|
||||
..addText('world. ')
|
||||
// The pop() command signals the end of the bold styling.
|
||||
..pop()
|
||||
// We add text to the paragraph in logical order. The paragraph object
|
||||
// understands bi-directional text and will compute the visual ordering
|
||||
// during layout.
|
||||
..addText('هذا هو قليلا طويلة من النص الذي يجب التفاف .')
|
||||
// The second pop() removes the blue color.
|
||||
..pop()
|
||||
// We can add more text with the default styling.
|
||||
..addText(' و أكثر قليلا لجعله أطول. ')
|
||||
..addText('สวัสดี');
|
||||
// When we're done adding styles and text, we build the Paragraph object, at
|
||||
// which time we can apply styling that affects the entire paragraph, such as
|
||||
// left, right, or center alignment. Once built, the contents of the paragraph
|
||||
// cannot be altered, but sizing and positioning information can be updated.
|
||||
paragraph = builder.build()
|
||||
// Next, we supply a width that the text is permitted to occupy and we ask
|
||||
// the paragraph to the visual position of each its glyphs as well as its
|
||||
// overall size, subject to its sizing constraints.
|
||||
..layout(const ui.ParagraphConstraints(width: 180.0));
|
||||
paragraph =
|
||||
builder.build()
|
||||
// Next, we supply a width that the text is permitted to occupy and we ask
|
||||
// the paragraph to the visual position of each its glyphs as well as its
|
||||
// overall size, subject to its sizing constraints.
|
||||
..layout(const ui.ParagraphConstraints(width: 180.0));
|
||||
|
||||
// Finally, we register our beginFrame callback and kick off the first frame.
|
||||
ui.PlatformDispatcher.instance
|
||||
..onBeginFrame = beginFrame
|
||||
..scheduleFrame();
|
||||
..onBeginFrame = beginFrame
|
||||
..scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -49,20 +49,22 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = view.devicePixelRatio;
|
||||
|
||||
// This transform scales the x and y coordinates by the devicePixelRatio.
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final Float64List deviceTransform =
|
||||
Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
|
||||
// We build a very simple scene graph with two nodes. The root node is a
|
||||
// transform that scale its children by the device pixel ratio. This transform
|
||||
// lets us paint in "logical" pixels which are converted to device pixels by
|
||||
// this scaling operation.
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
final ui.SceneBuilder sceneBuilder =
|
||||
ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
|
||||
// When we're done recording the scene, we call build() to obtain an immutable
|
||||
// record of the scene we've recorded.
|
||||
|
||||
Reference in New Issue
Block a user