mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
I ran this and fixed some of the warnings flagged: cd ~/dev/mojo/src/sky && find engine/core/painting sdk/example sdk/lib -type f -name '*.dart' | perl -nE 'chomp; local $/ = undef; open(FILE, $_); my $file = <FILE>; print $file; next if $file =~ /^part of/om; say "import \"$_\";"' > all.dart && shelldb analyze all.dart 2>&1 | grep -v 'sky/all.dart' Then I loaded the affected examples and fixed any bugs I found from running them. Major change to SDK: - Fix RenderPadding to get a valid size when it has no child (it was previously sizing itself too small by the padding amount). Minor changes, mostly to examples: - Fix the 'part of' lines in sky_shell_dart_controller_service_isolate to match the library name given in main.dart. - Remove unused imports in various places. - Fix example/game/lib/texture.dart to use the new Rect creation APIs. - Remove unused code in example/mine_digger/lib/main.dart. - Fix example/raw/hello_world.dart to use the new Size.center API. - Fix example/rendering/baseline.dart and example/rendering/justify_content.dart to have readable text. - Fix compile error in example/rendering/transform.dart. - Extend the debugDoesMeetConstraints() method to print useful information when it will be used to fire an assert. - Remove a warning about abstract methods on RenderView that would for some reason only sometimes get flagged by the analyzer. R=abarth@chromium.org, jackson@google.com Review URL: https://codereview.chromium.org/1215163003.
79 lines
2.4 KiB
Dart
79 lines
2.4 KiB
Dart
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:sky' as sky;
|
|
|
|
import 'package:sky/painting/text_style.dart';
|
|
import 'package:sky/rendering/block.dart';
|
|
import 'package:sky/rendering/box.dart';
|
|
import 'package:sky/rendering/object.dart';
|
|
import 'package:sky/rendering/paragraph.dart';
|
|
import 'package:sky/rendering/sky_binding.dart';
|
|
|
|
RenderBox getBox(double lh) {
|
|
RenderParagraph paragraph = new RenderParagraph(
|
|
new InlineStyle(
|
|
new TextStyle(
|
|
color: const Color(0xFF0000A0)
|
|
),
|
|
[
|
|
new InlineText('test'),
|
|
new InlineStyle(
|
|
new TextStyle(
|
|
fontFamily: 'serif',
|
|
fontSize: 50.0,
|
|
height: lh
|
|
),
|
|
[new InlineText('مرحبا Hello')]
|
|
)
|
|
]
|
|
)
|
|
);
|
|
return new RenderPadding(
|
|
padding: new EdgeDims.all(10.0),
|
|
child: new RenderConstrainedBox(
|
|
additionalConstraints: new BoxConstraints.tightFor(height: 200.0),
|
|
child: new RenderDecoratedBox(
|
|
decoration: new BoxDecoration(
|
|
backgroundColor: const Color(0xFFFFFFFF)
|
|
),
|
|
child: new RenderPadding(
|
|
padding: new EdgeDims.all(10.0),
|
|
child: new RenderCustomPaint(
|
|
child: paragraph,
|
|
callback: (canvas, size) {
|
|
double baseline = paragraph.getDistanceToBaseline(TextBaseline.alphabetic);
|
|
double w = paragraph.getMaxIntrinsicWidth(new BoxConstraints.loose(size));
|
|
double h = paragraph.getMaxIntrinsicHeight(new BoxConstraints.loose(size));
|
|
Path path = new Path();
|
|
path.moveTo(0.0, 0.0);
|
|
path.lineTo(w, 0.0);
|
|
path.moveTo(0.0, baseline);
|
|
path.lineTo(w, baseline);
|
|
path.moveTo(0.0, h);
|
|
path.lineTo(w, h);
|
|
Paint paint = new Paint();
|
|
paint.color = const Color(0xFFFF9000);
|
|
paint.setStyle(sky.PaintingStyle.stroke);
|
|
paint.strokeWidth = 3.0;
|
|
canvas.drawPath(path, paint);
|
|
}
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
RenderBox root = new RenderBlock(children: [
|
|
new RenderConstrainedBox(
|
|
additionalConstraints: new BoxConstraints.tightFor(height: 50.0)
|
|
),
|
|
getBox(1.0),
|
|
getBox(null),
|
|
]);
|
|
new SkyBinding(root: root);
|
|
}
|