Unnecessary new (#20138)

* enable lint unnecessary_new

* fix tests

* fix tests

* fix tests
This commit is contained in:
Alexandre Ardhuin
2018-09-12 08:29:29 +02:00
committed by GitHub
parent d7a0dcaa4a
commit d927c93310
1285 changed files with 26519 additions and 26519 deletions

View File

@@ -20,7 +20,7 @@ List<Color> _kColors = <Color>[
/// A simple model object for a dot that reacts to pointer pressure.
class Dot {
Dot({ Color color }) : _paint = new Paint()..color = color;
Dot({ Color color }) : _paint = Paint()..color = color;
final Paint _paint;
Offset position = Offset.zero;
@@ -66,7 +66,7 @@ class RenderDots extends RenderBox {
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
if (event is PointerDownEvent) {
final Color color = _kColors[event.pointer.remainder(_kColors.length)];
_dots[event.pointer] = new Dot(color: color)..update(event);
_dots[event.pointer] = Dot(color: color)..update(event);
// We call markNeedsPaint to indicate that our painting commands have
// changed and that paint needs to be called before displaying a new frame
// to the user. It's harmless to call markNeedsPaint multiple times
@@ -91,7 +91,7 @@ class RenderDots extends RenderBox {
// Passing offset during the render tree's paint walk is an optimization to
// avoid having to change the origin of the canvas's coordinate system too
// often.
canvas.drawRect(offset & size, new Paint()..color = const Color(0xFFFFFFFF));
canvas.drawRect(offset & size, Paint()..color = const Color(0xFFFFFFFF));
// We iterate through our model and paint each dot.
for (Dot dot in _dots.values)
@@ -101,7 +101,7 @@ class RenderDots extends RenderBox {
void main() {
// Create some styled text to tell the user to interact with the app.
final RenderParagraph paragraph = new RenderParagraph(
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(
style: TextStyle(color: Colors.black87),
text: 'Touch me!',
@@ -111,10 +111,10 @@ void main() {
// A stack is a render object that layers its children on top of each other.
// The bottom later is our RenderDots object, and on top of that we show the
// text.
final RenderStack stack = new RenderStack(
final RenderStack stack = RenderStack(
textDirection: TextDirection.ltr,
children: <RenderBox>[
new RenderDots(),
RenderDots(),
paragraph,
],
);
@@ -132,5 +132,5 @@ void main() {
..left = 20.0;
// Finally, we attach the render tree we've built to the screen.
new RenderingFlutterBinding(root: stack);
RenderingFlutterBinding(root: stack);
}