Unnecessary new (#20138) * enable lint unnecessary_new * fix tests * fix tests * fix tests
diff --git a/dev/manual_tests/lib/animated_icons.dart b/dev/manual_tests/lib/animated_icons.dart index 216a97b..718dba8 100644 --- a/dev/manual_tests/lib/animated_icons.dart +++ b/dev/manual_tests/lib/animated_icons.dart
@@ -7,7 +7,7 @@ class AnimatedIconsTestApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Animated Icons Test', home: const Scaffold( body: IconsList(), @@ -21,8 +21,8 @@ @override Widget build(BuildContext context) { - return new ListView( - children: samples.map((IconSample s) => new IconSampleRow(s)).toList(), + return ListView( + children: samples.map((IconSample s) => IconSampleRow(s)).toList(), ); } } @@ -33,7 +33,7 @@ final IconSample sample; @override - State createState() => new IconSampleRowState(); + State createState() => IconSampleRowState(); } class IconSampleRowState extends State<IconSampleRow> with SingleTickerProviderStateMixin { @@ -41,17 +41,17 @@ @override Widget build(BuildContext context) { - return new ListTile( - leading: new InkWell( + return ListTile( + leading: InkWell( onTap: () { progress.forward(from: 0.0); }, - child: new AnimatedIcon( + child: AnimatedIcon( icon: widget.sample.icon, progress: progress, color: Colors.lightBlue, ), ), - title: new Text(widget.sample.description), - subtitle: new Slider( + title: Text(widget.sample.description), + subtitle: Slider( value: progress.value, onChanged: (double v) { progress.animateTo(v, duration: Duration.zero); }, ), @@ -61,7 +61,7 @@ @override void initState() { super.initState(); - progress = new AnimationController(vsync: this, duration: const Duration(milliseconds: 300)); + progress = AnimationController(vsync: this, duration: const Duration(milliseconds: 300)); progress.addListener(_handleChange); } @@ -105,4 +105,4 @@ final String description; } -void main() => runApp(new AnimatedIconsTestApp()); +void main() => runApp(AnimatedIconsTestApp());
diff --git a/dev/manual_tests/lib/card_collection.dart b/dev/manual_tests/lib/card_collection.dart index 958fd57..896ec52 100644 --- a/dev/manual_tests/lib/card_collection.dart +++ b/dev/manual_tests/lib/card_collection.dart
@@ -9,18 +9,18 @@ class CardModel { CardModel(this.value, this.height) { - textController = new TextEditingController(text: 'Item $value'); + textController = TextEditingController(text: 'Item $value'); } int value; double height; int get color => ((value % 9) + 1) * 100; TextEditingController textController; - Key get key => new ObjectKey(this); + Key get key => ObjectKey(this); } class CardCollection extends StatefulWidget { @override - CardCollectionState createState() => new CardCollectionState(); + CardCollectionState createState() => CardCollectionState(); } class CardCollectionState extends State<CardCollection> { @@ -51,7 +51,7 @@ void _updateCardSizes() { if (_fixedSizeCards) return; - _cardModels = new List<CardModel>.generate( + _cardModels = List<CardModel>.generate( _cardModels.length, (int i) { _cardModels[i].height = _editable ? max(_cardHeights[i], 60.0) : _cardHeights[i]; @@ -61,17 +61,17 @@ } void _initVariableSizedCardModels() { - _cardModels = new List<CardModel>.generate( + _cardModels = List<CardModel>.generate( _cardHeights.length, - (int i) => new CardModel(i, _editable ? max(_cardHeights[i], 60.0) : _cardHeights[i]) + (int i) => CardModel(i, _editable ? max(_cardHeights[i], 60.0) : _cardHeights[i]) ); } void _initFixedSizedCardModels() { const int cardCount = 27; - _cardModels = new List<CardModel>.generate( + _cardModels = List<CardModel>.generate( cardCount, - (int i) => new CardModel(i, kFixedCardHeight), + (int i) => CardModel(i, kFixedCardHeight), ); } @@ -97,10 +97,10 @@ } Widget _buildDrawer() { - return new Drawer( - child: new IconTheme( + return Drawer( + child: IconTheme( data: const IconThemeData(color: Colors.black), - child: new ListView( + child: ListView( children: <Widget>[ const DrawerHeader(child: Center(child: Text('Options'))), buildDrawerCheckbox('Make card labels editable', _editable, _toggleEditable), @@ -121,7 +121,7 @@ buildFontRadioItem('Center-align text', TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable), buildFontRadioItem('Right-align text', TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable), const Divider(), - new ListTile( + ListTile( leading: const Icon(Icons.dvr), onTap: () { debugDumpApp(); debugDumpRenderTree(); }, title: const Text('Dump App to Console'), @@ -182,10 +182,10 @@ } Widget buildDrawerCheckbox(String label, bool value, void callback(), { bool enabled = true }) { - return new ListTile( + return ListTile( onTap: enabled ? callback : null, - title: new Text(label), - trailing: new Checkbox( + title: Text(label), + trailing: Checkbox( value: value, onChanged: enabled ? (_) { callback(); } : null, ), @@ -193,11 +193,11 @@ } Widget buildDrawerColorRadioItem(String label, MaterialColor itemValue, MaterialColor currentValue, ValueChanged<MaterialColor> onChanged, { IconData icon, bool enabled = true }) { - return new ListTile( - leading: new Icon(icon), - title: new Text(label), + return ListTile( + leading: Icon(icon), + title: Text(label), onTap: enabled ? () { onChanged(itemValue); } : null, - trailing: new Radio<MaterialColor>( + trailing: Radio<MaterialColor>( value: itemValue, groupValue: currentValue, onChanged: enabled ? onChanged : null, @@ -206,11 +206,11 @@ } Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection> onChanged, { IconData icon, bool enabled = true }) { - return new ListTile( - leading: new Icon(icon), - title: new Text(label), + return ListTile( + leading: Icon(icon), + title: Text(label), onTap: enabled ? () { onChanged(itemValue); } : null, - trailing: new Radio<DismissDirection>( + trailing: Radio<DismissDirection>( value: itemValue, groupValue: currentValue, onChanged: enabled ? onChanged : null, @@ -219,11 +219,11 @@ } Widget buildFontRadioItem(String label, TextAlign itemValue, TextAlign currentValue, ValueChanged<TextAlign> onChanged, { IconData icon, bool enabled = true }) { - return new ListTile( - leading: new Icon(icon), - title: new Text(label), + return ListTile( + leading: Icon(icon), + title: Text(label), onTap: enabled ? () { onChanged(itemValue); } : null, - trailing: new Radio<TextAlign>( + trailing: Radio<TextAlign>( value: itemValue, groupValue: currentValue, onChanged: enabled ? onChanged : null, @@ -232,34 +232,34 @@ } Widget _buildAppBar(BuildContext context) { - return new AppBar( + return AppBar( actions: <Widget>[ - new Text(_dismissDirectionText(_dismissDirection)) + Text(_dismissDirectionText(_dismissDirection)) ], - flexibleSpace: new Container( + flexibleSpace: Container( padding: const EdgeInsets.only(left: 72.0), height: 128.0, alignment: const Alignment(-1.0, 0.5), - child: new Text('Swipe Away: ${_cardModels.length}', style: Theme.of(context).primaryTextTheme.title), + child: Text('Swipe Away: ${_cardModels.length}', style: Theme.of(context).primaryTextTheme.title), ), ); } Widget _buildCard(BuildContext context, int index) { final CardModel cardModel = _cardModels[index]; - final Widget card = new Dismissible( - key: new ObjectKey(cardModel), + final Widget card = Dismissible( + key: ObjectKey(cardModel), direction: _dismissDirection, onDismissed: (DismissDirection direction) { dismissCard(cardModel); }, - child: new Card( + child: Card( color: _primaryColor[cardModel.color], - child: new Container( + child: Container( height: cardModel.height, padding: const EdgeInsets.all(kCardMargins), child: _editable ? - new Center( - child: new TextField( - key: new GlobalObjectKey(cardModel), + Center( + child: TextField( + key: GlobalObjectKey(cardModel), controller: cardModel.textController, ), ) @@ -267,11 +267,11 @@ style: cardLabelStyle.copyWith( fontSize: _varyFontSizes ? 5.0 + index : null ), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ - new Text(cardModel.textController.text, textAlign: _textAlign), + Text(cardModel.textController.text, textAlign: _textAlign), ], ), ), @@ -297,12 +297,12 @@ // TODO(abarth): This icon is wrong in RTL. Widget leftArrowIcon = const Icon(Icons.arrow_back, size: 36.0); if (_dismissDirection == DismissDirection.startToEnd) - leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon); + leftArrowIcon = Opacity(opacity: 0.1, child: leftArrowIcon); // TODO(abarth): This icon is wrong in RTL. Widget rightArrowIcon = const Icon(Icons.arrow_forward, size: 36.0); if (_dismissDirection == DismissDirection.endToStart) - rightArrowIcon = new Opacity(opacity: 0.1, child: rightArrowIcon); + rightArrowIcon = Opacity(opacity: 0.1, child: rightArrowIcon); final ThemeData theme = Theme.of(context); final TextStyle backgroundTextStyle = theme.primaryTextTheme.title; @@ -312,18 +312,18 @@ // size of the background,card Stack will be based only on the card. The // Viewport ensures that when the card's resize animation occurs, the // background (text and icons) will just be clipped, not resized. - final Widget background = new Positioned.fill( - child: new Container( + final Widget background = Positioned.fill( + child: Container( margin: const EdgeInsets.all(4.0), - child: new SingleChildScrollView( - child: new Container( + child: SingleChildScrollView( + child: Container( height: cardModel.height, color: theme.primaryColor, - child: new Row( + child: Row( children: <Widget>[ leftArrowIcon, - new Expanded( - child: new Text(backgroundMessage, + Expanded( + child: Text(backgroundMessage, style: backgroundTextStyle, textAlign: TextAlign.center, ), @@ -336,10 +336,10 @@ ), ); - return new IconTheme( + return IconTheme( key: cardModel.key, data: const IconThemeData(color: Colors.white), - child: new Stack(children: <Widget>[background, card]), + child: Stack(children: <Widget>[background, card]), ); } @@ -355,32 +355,32 @@ @override Widget build(BuildContext context) { - Widget cardCollection = new ListView.builder( + Widget cardCollection = ListView.builder( itemExtent: _fixedSizeCards ? kFixedCardHeight : null, itemCount: _cardModels.length, itemBuilder: _buildCard, ); if (_sunshine) { - cardCollection = new Stack( + cardCollection = Stack( children: <Widget>[ - new Column(children: <Widget>[new Image.network(_sunshineURL)]), - new ShaderMask(child: cardCollection, shaderCallback: _createShader), + Column(children: <Widget>[Image.network(_sunshineURL)]), + ShaderMask(child: cardCollection, shaderCallback: _createShader), ], ); } - final Widget body = new Container( + final Widget body = Container( padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), color: _primaryColor.shade50, child: cardCollection, ); - return new Theme( - data: new ThemeData( + return Theme( + data: ThemeData( primarySwatch: _primaryColor, ), - child: new Scaffold( + child: Scaffold( appBar: _buildAppBar(context), drawer: _buildDrawer(), body: body, @@ -390,8 +390,8 @@ } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Cards', - home: new CardCollection(), + home: CardCollection(), )); }
diff --git a/dev/manual_tests/lib/color_testing_demo.dart b/dev/manual_tests/lib/color_testing_demo.dart index 31f2265..9efc544 100644 --- a/dev/manual_tests/lib/color_testing_demo.dart +++ b/dev/manual_tests/lib/color_testing_demo.dart
@@ -11,20 +11,20 @@ static const String routeName = '/color_demo'; @override - Widget build(BuildContext context) => new ColorDemoHome(); + Widget build(BuildContext context) => ColorDemoHome(); } class ColorDemoHome extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Color Demo')), - body: new ListView( + return Scaffold( + appBar: AppBar(title: const Text('Color Demo')), + body: ListView( padding: const EdgeInsets.all(5.0), children: <Widget>[ - new Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/gbr.png'), - new Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/tf.png'), - new Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/wide-gamut.png'), + Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/gbr.png'), + Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/tf.png'), + Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/wide-gamut.png'), const GradientRow(leftColor: Color(0xFFFF0000), rightColor: Color(0xFF00FF00)), const GradientRow(leftColor: Color(0xFF0000FF), rightColor: Color(0xFFFFFF00)), const GradientRow(leftColor: Color(0xFFFF0000), rightColor: Color(0xFF0000FF)), @@ -58,10 +58,10 @@ @override Widget build(BuildContext context) { - return new Container( + return Container( height: 100.0, - decoration: new BoxDecoration( - gradient: new LinearGradient( + decoration: BoxDecoration( + gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[ leftColor, rightColor ], @@ -78,7 +78,7 @@ @override Widget build(BuildContext context) { - return new Container( + return Container( height: 100.0, color: color, ); @@ -86,8 +86,8 @@ } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Color Testing Demo', - home: new ColorDemoHome(), + home: ColorDemoHome(), )); }
diff --git a/dev/manual_tests/lib/drag_and_drop.dart b/dev/manual_tests/lib/drag_and_drop.dart index 39cdeae..cc27bf7 100644 --- a/dev/manual_tests/lib/drag_and_drop.dart +++ b/dev/manual_tests/lib/drag_and_drop.dart
@@ -8,7 +8,7 @@ class ExampleDragTarget extends StatefulWidget { @override - ExampleDragTargetState createState() => new ExampleDragTargetState(); + ExampleDragTargetState createState() => ExampleDragTargetState(); } class ExampleDragTargetState extends State<ExampleDragTarget> { @@ -22,15 +22,15 @@ @override Widget build(BuildContext context) { - return new DragTarget<Color>( + return DragTarget<Color>( onAccept: _handleAccept, builder: (BuildContext context, List<Color> data, List<dynamic> rejectedData) { - return new Container( + return Container( height: 100.0, margin: const EdgeInsets.all(10.0), - decoration: new BoxDecoration( + decoration: BoxDecoration( color: data.isEmpty ? _color : Colors.grey.shade200, - border: new Border.all( + border: Border.all( width: 3.0, color: data.isEmpty ? Colors.white : Colors.blue ), @@ -50,21 +50,21 @@ final bool tappable; @override - DotState createState() => new DotState(); + DotState createState() => DotState(); } class DotState extends State<Dot> { int taps = 0; @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: widget.tappable ? () { setState(() { taps += 1; }); } : null, - child: new Container( + child: Container( width: widget.size, height: widget.size, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: widget.color, - border: new Border.all(width: taps.toDouble()), + border: Border.all(width: taps.toDouble()), shape: BoxShape.circle ), child: widget.child @@ -97,17 +97,17 @@ if (heavy) size *= kHeavyMultiplier; - final Widget contents = new DefaultTextStyle( + final Widget contents = DefaultTextStyle( style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center, - child: new Dot( + child: Dot( color: color, size: size, - child: new Center(child: child) + child: Center(child: child) ) ); - Widget feedback = new Opacity( + Widget feedback = Opacity( opacity: 0.75, child: contents ); @@ -115,8 +115,8 @@ Offset feedbackOffset; DragAnchor anchor; if (!under) { - feedback = new Transform( - transform: new Matrix4.identity() + feedback = Transform( + transform: Matrix4.identity() ..translate(-size / 2.0, -(size / 2.0 + kFingerSize)), child: feedback ); @@ -128,7 +128,7 @@ } if (heavy) { - return new LongPressDraggable<Color>( + return LongPressDraggable<Color>( data: color, child: contents, feedback: feedback, @@ -136,7 +136,7 @@ dragAnchor: anchor ); } else { - return new Draggable<Color>( + return Draggable<Color>( data: color, child: contents, feedback: feedback, @@ -158,11 +158,11 @@ @override void paint(Canvas canvas, Size size) { final double radius = size.shortestSide / 2.0; - final Paint paint = new Paint() + final Paint paint = Paint() ..color = const Color(0xFF000000) ..style = PaintingStyle.stroke ..strokeWidth = radius / 10.0; - final Path path = new Path(); + final Path path = Path(); final Rect box = Offset.zero & size; for (double theta = 0.0; theta < math.pi * 2.0; theta += deltaTheta) path.addArc(box, theta + startOffset, segmentArc); @@ -180,15 +180,15 @@ final int ballPosition; final ValueChanged<int> callback; - static final GlobalKey kBallKey = new GlobalKey(); + static final GlobalKey kBallKey = GlobalKey(); static const double kBallSize = 50.0; @override Widget build(BuildContext context) { - final Widget ball = new DefaultTextStyle( + final Widget ball = DefaultTextStyle( style: Theme.of(context).primaryTextTheme.body1, textAlign: TextAlign.center, - child: new Dot( + child: Dot( key: kBallKey, color: Colors.blue.shade700, size: kBallSize, @@ -196,7 +196,7 @@ child: const Center(child: Text('BALL')) ) ); - final Widget dashedBall = new Container( + final Widget dashedBall = Container( width: kBallSize, height: kBallSize, child: const CustomPaint( @@ -204,7 +204,7 @@ ) ); if (position == ballPosition) { - return new Draggable<bool>( + return Draggable<bool>( data: true, child: ball, childWhenDragging: dashedBall, @@ -212,7 +212,7 @@ maxSimultaneousDrags: 1 ); } else { - return new DragTarget<bool>( + return DragTarget<bool>( onAccept: (bool data) { callback(position); }, builder: (BuildContext context, List<bool> accepted, List<dynamic> rejected) { return dashedBall; @@ -224,7 +224,7 @@ class DragAndDropApp extends StatefulWidget { @override - DragAndDropAppState createState() => new DragAndDropAppState(); + DragAndDropAppState createState() => DragAndDropAppState(); } class DragAndDropAppState extends State<DragAndDropApp> { @@ -236,30 +236,30 @@ @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Drag and Drop Flutter Demo') ), - body: new Column( + body: Column( children: <Widget>[ - new Expanded( - child: new Row( + Expanded( + child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ - new ExampleDragSource( + ExampleDragSource( color: Colors.yellow.shade300, under: true, heavy: false, child: const Text('under') ), - new ExampleDragSource( + ExampleDragSource( color: Colors.green.shade300, under: false, heavy: true, child: const Text('long-press above') ), - new ExampleDragSource( + ExampleDragSource( color: Colors.indigo.shade300, under: false, heavy: false, @@ -268,23 +268,23 @@ ], ) ), - new Expanded( - child: new Row( + Expanded( + child: Row( children: <Widget>[ - new Expanded(child: new ExampleDragTarget()), - new Expanded(child: new ExampleDragTarget()), - new Expanded(child: new ExampleDragTarget()), - new Expanded(child: new ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), ] ) ), - new Expanded( - child: new Row( + Expanded( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ - new MovableBall(1, position, moveBall), - new MovableBall(2, position, moveBall), - new MovableBall(3, position, moveBall), + MovableBall(1, position, moveBall), + MovableBall(2, position, moveBall), + MovableBall(3, position, moveBall), ], ) ), @@ -295,8 +295,8 @@ } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Drag and Drop Flutter Demo', - home: new DragAndDropApp() + home: DragAndDropApp() )); }
diff --git a/dev/manual_tests/lib/material_arc.dart b/dev/manual_tests/lib/material_arc.dart index d8aa502..e4afb81 100644 --- a/dev/manual_tests/lib/material_arc.dart +++ b/dev/manual_tests/lib/material_arc.dart
@@ -55,7 +55,7 @@ final Animation<double> _repaint; void drawPoint(Canvas canvas, Offset point, Color color) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color.withOpacity(0.25) ..style = PaintingStyle.fill; canvas.drawCircle(point, _kPointRadius, paint); @@ -68,7 +68,7 @@ @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint(); + final Paint paint = Paint(); if (arc.center != null) drawPoint(canvas, arc.center, Colors.grey.shade400); @@ -108,11 +108,11 @@ final AnimationController controller; @override - _PointDemoState createState() => new _PointDemoState(); + _PointDemoState createState() => _PointDemoState(); } class _PointDemoState extends State<_PointDemo> { - final GlobalKey _painterKey = new GlobalKey(); + final GlobalKey _painterKey = GlobalKey(); CurvedAnimation _animation; _DragTarget _dragTarget; @@ -123,7 +123,7 @@ @override void initState() { super.initState(); - _animation = new CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); + _animation = CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); } @override @@ -135,7 +135,7 @@ Drag _handleOnStart(Offset position) { // TODO(hansmuller): allow the user to drag both points at the same time. if (_dragTarget != null) - return new _IgnoreDrag(); + return _IgnoreDrag(); final RenderBox box = _painterKey.currentContext.findRenderObject(); final double startOffset = (box.localToGlobal(_begin) - position).distanceSquared; @@ -149,7 +149,7 @@ _dragTarget = null; }); - return new _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); + return _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); } void _handleDragUpdate(DragUpdateDetails details) { @@ -181,36 +181,36 @@ final Size screenSize = MediaQuery.of(context).size; if (_screenSize == null || _screenSize != screenSize) { _screenSize = screenSize; - _begin = new Offset(screenSize.width * 0.5, screenSize.height * 0.2); - _end = new Offset(screenSize.width * 0.1, screenSize.height * 0.4); + _begin = Offset(screenSize.width * 0.5, screenSize.height * 0.2); + _end = Offset(screenSize.width * 0.1, screenSize.height * 0.4); } - final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end); - return new RawGestureDetector( + final MaterialPointArcTween arc = MaterialPointArcTween(begin: _begin, end: _end); + return RawGestureDetector( behavior: _dragTarget == null ? HitTestBehavior.deferToChild : HitTestBehavior.opaque, gestures: <Type, GestureRecognizerFactory>{ - ImmediateMultiDragGestureRecognizer: new GestureRecognizerFactoryWithHandlers<ImmediateMultiDragGestureRecognizer>( - () => new ImmediateMultiDragGestureRecognizer(), + ImmediateMultiDragGestureRecognizer: GestureRecognizerFactoryWithHandlers<ImmediateMultiDragGestureRecognizer>( + () => ImmediateMultiDragGestureRecognizer(), (ImmediateMultiDragGestureRecognizer instance) { instance ..onStart = _handleOnStart; }, ), }, - child: new ClipRect( - child: new CustomPaint( + child: ClipRect( + child: CustomPaint( key: _painterKey, - foregroundPainter: new _PointDemoPainter( + foregroundPainter: _PointDemoPainter( repaint: _animation, arc: arc ), // Watch out: if this IgnorePointer is left out, then gestures that // fail _PointDemoPainter.hitTest() will still be recognized because // they do overlap this child, which is as big as the CustomPaint. - child: new IgnorePointer( - child: new Padding( + child: IgnorePointer( + child: Padding( padding: const EdgeInsets.all(16.0), - child: new Text( + child: Text( 'Tap the refresh button to run the animation. Drag the green ' "and red points to change the animation's path.", style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0) @@ -233,7 +233,7 @@ final Animation<double> _repaint; void drawPoint(Canvas canvas, Offset p, Color color) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color.withOpacity(0.25) ..style = PaintingStyle.fill; canvas.drawCircle(p, _kPointRadius, paint); @@ -245,7 +245,7 @@ } void drawRect(Canvas canvas, Rect rect, Color color) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color.withOpacity(0.25) ..strokeWidth = 4.0 ..style = PaintingStyle.stroke; @@ -276,11 +276,11 @@ final AnimationController controller; @override - _RectangleDemoState createState() => new _RectangleDemoState(); + _RectangleDemoState createState() => _RectangleDemoState(); } class _RectangleDemoState extends State<_RectangleDemo> { - final GlobalKey _painterKey = new GlobalKey(); + final GlobalKey _painterKey = GlobalKey(); CurvedAnimation _animation; _DragTarget _dragTarget; @@ -291,7 +291,7 @@ @override void initState() { super.initState(); - _animation = new CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); + _animation = CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); } @override @@ -303,7 +303,7 @@ Drag _handleOnStart(Offset position) { // TODO(hansmuller): allow the user to drag both points at the same time. if (_dragTarget != null) - return new _IgnoreDrag(); + return _IgnoreDrag(); final RenderBox box = _painterKey.currentContext.findRenderObject(); final double startOffset = (box.localToGlobal(_begin.center) - position).distanceSquared; @@ -316,7 +316,7 @@ else _dragTarget = null; }); - return new _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); + return _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); } void _handleDragUpdate(DragUpdateDetails details) { @@ -348,42 +348,42 @@ final Size screenSize = MediaQuery.of(context).size; if (_screenSize == null || _screenSize != screenSize) { _screenSize = screenSize; - _begin = new Rect.fromLTWH( + _begin = Rect.fromLTWH( screenSize.width * 0.5, screenSize.height * 0.2, screenSize.width * 0.4, screenSize.height * 0.2 ); - _end = new Rect.fromLTWH( + _end = Rect.fromLTWH( screenSize.width * 0.1, screenSize.height * 0.4, screenSize.width * 0.3, screenSize.height * 0.3 ); } - final MaterialRectArcTween arc = new MaterialRectArcTween(begin: _begin, end: _end); - return new RawGestureDetector( + final MaterialRectArcTween arc = MaterialRectArcTween(begin: _begin, end: _end); + return RawGestureDetector( behavior: _dragTarget == null ? HitTestBehavior.deferToChild : HitTestBehavior.opaque, gestures: <Type, GestureRecognizerFactory>{ - ImmediateMultiDragGestureRecognizer: new GestureRecognizerFactoryWithHandlers<ImmediateMultiDragGestureRecognizer>( - () => new ImmediateMultiDragGestureRecognizer(), + ImmediateMultiDragGestureRecognizer: GestureRecognizerFactoryWithHandlers<ImmediateMultiDragGestureRecognizer>( + () => ImmediateMultiDragGestureRecognizer(), (ImmediateMultiDragGestureRecognizer instance) { instance ..onStart = _handleOnStart; }, ), }, - child: new ClipRect( - child: new CustomPaint( + child: ClipRect( + child: CustomPaint( key: _painterKey, - foregroundPainter: new _RectangleDemoPainter( + foregroundPainter: _RectangleDemoPainter( repaint: _animation, arc: arc ), // Watch out: if this IgnorePointer is left out, then gestures that // fail _RectDemoPainter.hitTest() will still be recognized because // they do overlap this child, which is as big as the CustomPaint. - child: new IgnorePointer( - child: new Padding( + child: IgnorePointer( + child: Padding( padding: const EdgeInsets.all(16.0), - child: new Text( + child: Text( 'Tap the refresh button to run the animation. Drag the rectangles ' "to change the animation's path.", style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0) @@ -400,8 +400,8 @@ class _ArcDemo { _ArcDemo(this.title, this.builder, TickerProvider vsync) - : controller = new AnimationController(duration: const Duration(milliseconds: 500), vsync: vsync), - key = new GlobalKey(debugLabel: title); + : controller = AnimationController(duration: const Duration(milliseconds: 500), vsync: vsync), + key = GlobalKey(debugLabel: title); final String title; final _DemoBuilder builder; @@ -413,7 +413,7 @@ const AnimationDemo({ Key key }) : super(key: key); @override - _AnimationDemoState createState() => new _AnimationDemoState(); + _AnimationDemoState createState() => _AnimationDemoState(); } class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateMixin { @@ -423,14 +423,14 @@ void initState() { super.initState(); _allDemos = <_ArcDemo>[ - new _ArcDemo('POINT', (_ArcDemo demo) { - return new _PointDemo( + _ArcDemo('POINT', (_ArcDemo demo) { + return _PointDemo( key: demo.key, controller: demo.controller ); }, this), - new _ArcDemo('RECTANGLE', (_ArcDemo demo) { - return new _RectangleDemo( + _ArcDemo('RECTANGLE', (_ArcDemo demo) { + return _RectangleDemo( key: demo.key, controller: demo.controller ); @@ -446,18 +446,18 @@ @override Widget build(BuildContext context) { - return new DefaultTabController( + return DefaultTabController( length: _allDemos.length, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('Animation'), - bottom: new TabBar( - tabs: _allDemos.map((_ArcDemo demo) => new Tab(text: demo.title)).toList(), + bottom: TabBar( + tabs: _allDemos.map((_ArcDemo demo) => Tab(text: demo.title)).toList(), ), ), - floatingActionButton: new Builder( + floatingActionButton: Builder( builder: (BuildContext context) { - return new FloatingActionButton( + return FloatingActionButton( child: const Icon(Icons.refresh), onPressed: () { _play(_allDemos[DefaultTabController.of(context).index]); @@ -465,7 +465,7 @@ ); }, ), - body: new TabBarView( + body: TabBarView( children: _allDemos.map((_ArcDemo demo) => demo.builder(demo)).toList() ) ) @@ -474,7 +474,7 @@ } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( home: const AnimationDemo(), )); }
diff --git a/dev/manual_tests/lib/overlay_geometry.dart b/dev/manual_tests/lib/overlay_geometry.dart index be8a2f9..e73cb75 100644 --- a/dev/manual_tests/lib/overlay_geometry.dart +++ b/dev/manual_tests/lib/overlay_geometry.dart
@@ -14,8 +14,8 @@ Color color; String get label => 'Card $value'; - Key get key => new ObjectKey(this); - GlobalKey get targetKey => new GlobalObjectKey(this); + Key get key => ObjectKey(this); + GlobalKey get targetKey => GlobalObjectKey(this); } enum MarkerType { topLeft, bottomRight, touch } @@ -31,21 +31,21 @@ @override void paint(Canvas canvas, _) { - final Paint paint = new Paint()..color = const Color(0x8000FF00); + final Paint paint = Paint()..color = const Color(0x8000FF00); final double r = size / 2.0; - canvas.drawCircle(new Offset(r, r), r, paint); + canvas.drawCircle(Offset(r, r), r, paint); paint ..color = const Color(0xFFFFFFFF) ..style = PaintingStyle.stroke ..strokeWidth = 1.0; if (type == MarkerType.topLeft) { - canvas.drawLine(new Offset(r, r), new Offset(r + r - 1.0, r), paint); - canvas.drawLine(new Offset(r, r), new Offset(r, r + r - 1.0), paint); + canvas.drawLine(Offset(r, r), Offset(r + r - 1.0, r), paint); + canvas.drawLine(Offset(r, r), Offset(r, r + r - 1.0), paint); } if (type == MarkerType.bottomRight) { - canvas.drawLine(new Offset(r, r), new Offset(1.0, r), paint); - canvas.drawLine(new Offset(r, r), new Offset(r, 1.0), paint); + canvas.drawLine(Offset(r, r), Offset(1.0, r), paint); + canvas.drawLine(Offset(r, r), Offset(r, 1.0), paint); } } @@ -70,14 +70,14 @@ @override Widget build(BuildContext context) { - return new Positioned( + return Positioned( left: position.dx - size / 2.0, top: position.dy - size / 2.0, width: size, height: size, - child: new IgnorePointer( - child: new CustomPaint( - painter: new _MarkerPainter( + child: IgnorePointer( + child: CustomPaint( + painter: _MarkerPainter( size: size, type: type, ), @@ -89,7 +89,7 @@ class OverlayGeometryApp extends StatefulWidget { @override - OverlayGeometryAppState createState() => new OverlayGeometryAppState(); + OverlayGeometryAppState createState() => OverlayGeometryAppState(); } typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition); @@ -108,16 +108,16 @@ if (index >= cardModels.length) return null; final CardModel cardModel = cardModels[index]; - return new GestureDetector( + return GestureDetector( key: cardModel.key, onTapUp: (TapUpDetails details) { onTapUp(cardModel.targetKey, details.globalPosition); }, - child: new Card( + child: Card( key: cardModel.targetKey, color: cardModel.color, - child: new Container( + child: Container( height: cardModel.height, padding: const EdgeInsets.all(8.0), - child: new Center(child: new Text(cardModel.label, style: cardLabelStyle)), + child: Center(child: Text(cardModel.label, style: cardLabelStyle)), ), ), ); @@ -145,9 +145,9 @@ 48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0, 48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0, ]; - cardModels = new List<CardModel>.generate(cardHeights.length, (int i) { + cardModels = List<CardModel>.generate(cardHeights.length, (int i) { final Color color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardHeights.length); - return new CardModel(i, cardHeights[i], color); + return CardModel(i, cardHeights[i], color); }); } @@ -171,7 +171,7 @@ final RenderBox box = target.currentContext.findRenderObject(); markers[MarkerType.topLeft] = box.localToGlobal(const Offset(0.0, 0.0)); final Size size = box.size; - markers[MarkerType.bottomRight] = box.localToGlobal(new Offset(size.width, size.height)); + markers[MarkerType.bottomRight] = box.localToGlobal(Offset(size.width, size.height)); final ScrollableState scrollable = Scrollable.of(target.currentContext); markersScrollOffset = scrollable.position.pixels; }); @@ -180,14 +180,14 @@ @override Widget build(BuildContext context) { final List<Widget> layers = <Widget>[ - new Scaffold( - appBar: new AppBar(title: const Text('Tap a Card')), - body: new Container( + Scaffold( + appBar: AppBar(title: const Text('Tap a Card')), + body: Container( padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), - child: new NotificationListener<ScrollNotification>( + child: NotificationListener<ScrollNotification>( onNotification: handleScrollNotification, - child: new ListView.custom( - childrenDelegate: new CardBuilder( + child: ListView.custom( + childrenDelegate: CardBuilder( cardModels: cardModels, onTapUp: handleTapUp, ), @@ -197,19 +197,19 @@ ), ]; for (MarkerType type in markers.keys) - layers.add(new Marker(type: type, position: markers[type])); - return new Stack(children: layers); + layers.add(Marker(type: type, position: markers[type])); + return Stack(children: layers); } } void main() { - runApp(new MaterialApp( - theme: new ThemeData( + runApp(MaterialApp( + theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.blue, accentColor: Colors.redAccent, ), title: 'Cards', - home: new OverlayGeometryApp(), + home: OverlayGeometryApp(), )); }
diff --git a/dev/manual_tests/lib/page_view.dart b/dev/manual_tests/lib/page_view.dart index 0730f4a..5487f08 100644 --- a/dev/manual_tests/lib/page_view.dart +++ b/dev/manual_tests/lib/page_view.dart
@@ -10,12 +10,12 @@ Size size; Color color; String get label => 'Card $value'; - Key get key => new ObjectKey(this); + Key get key => ObjectKey(this); } class PageViewApp extends StatefulWidget { @override - PageViewAppState createState() => new PageViewAppState(); + PageViewAppState createState() => PageViewAppState(); } class PageViewAppState extends State<PageViewApp> { @@ -30,9 +30,9 @@ Size(300.0, 400.0), ]; - cardModels = new List<CardModel>.generate(cardSizes.length, (int i) { + cardModels = List<CardModel>.generate(cardSizes.length, (int i) { final Color color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardSizes.length); - return new CardModel(i, cardSizes[i], color); + return CardModel(i, cardSizes[i], color); }); } @@ -45,24 +45,24 @@ bool itemsWrap = false; Widget buildCard(CardModel cardModel) { - final Widget card = new Card( + final Widget card = Card( color: cardModel.color, - child: new Container( + child: Container( width: cardModel.size.width, height: cardModel.size.height, padding: const EdgeInsets.all(8.0), - child: new Center(child: new Text(cardModel.label, style: cardLabelStyle)), + child: Center(child: Text(cardModel.label, style: cardLabelStyle)), ), ); final BoxConstraints constraints = (scrollDirection == Axis.vertical) - ? new BoxConstraints.tightFor(height: pageSize.height) - : new BoxConstraints.tightFor(width: pageSize.width); + ? BoxConstraints.tightFor(height: pageSize.height) + : BoxConstraints.tightFor(width: pageSize.width); - return new Container( + return Container( key: cardModel.key, constraints: constraints, - child: new Center(child: card), + child: Center(child: card), ); } @@ -81,27 +81,27 @@ } Widget _buildDrawer() { - return new Drawer( - child: new ListView( + return Drawer( + child: ListView( children: <Widget>[ const DrawerHeader(child: Center(child: Text('Options'))), - new ListTile( + ListTile( leading: const Icon(Icons.more_horiz), selected: scrollDirection == Axis.horizontal, trailing: const Text('Horizontal Layout'), onTap: switchScrollDirection, ), - new ListTile( + ListTile( leading: const Icon(Icons.more_vert), selected: scrollDirection == Axis.vertical, trailing: const Text('Vertical Layout'), onTap: switchScrollDirection, ), - new ListTile( + ListTile( onTap: toggleItemsWrap, title: const Text('Scrolling wraps around'), // TODO(abarth): Actually make this checkbox change this value. - trailing: new Checkbox(value: itemsWrap, onChanged: null), + trailing: Checkbox(value: itemsWrap, onChanged: null), ), ], ), @@ -109,16 +109,16 @@ } Widget _buildAppBar() { - return new AppBar( + return AppBar( title: const Text('PageView'), actions: <Widget>[ - new Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'), + Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'), ], ); } Widget _buildBody(BuildContext context) { - return new PageView( + return PageView( children: cardModels.map(buildCard).toList(), // TODO(abarth): itemsWrap: itemsWrap, scrollDirection: scrollDirection, @@ -127,9 +127,9 @@ @override Widget build(BuildContext context) { - return new IconTheme( + return IconTheme( data: const IconThemeData(color: Colors.white), - child: new Scaffold( + child: Scaffold( appBar: _buildAppBar(), drawer: _buildDrawer(), body: _buildBody(context), @@ -139,13 +139,13 @@ } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'PageView', - theme: new ThemeData( + theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.blue, accentColor: Colors.redAccent, ), - home: new PageViewApp(), + home: PageViewApp(), )); }
diff --git a/dev/manual_tests/lib/raw_keyboard.dart b/dev/manual_tests/lib/raw_keyboard.dart index 69ccb05..cabbfe0 100644 --- a/dev/manual_tests/lib/raw_keyboard.dart +++ b/dev/manual_tests/lib/raw_keyboard.dart
@@ -6,10 +6,10 @@ import 'package:flutter/services.dart'; void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Hardware Key Demo', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Hardware Key Demo'), ), body: const Center( @@ -23,11 +23,11 @@ const RawKeyboardDemo({ Key key }) : super(key: key); @override - _HardwareKeyDemoState createState() => new _HardwareKeyDemoState(); + _HardwareKeyDemoState createState() => _HardwareKeyDemoState(); } class _HardwareKeyDemoState extends State<RawKeyboardDemo> { - final FocusNode _focusNode = new FocusNode(); + final FocusNode _focusNode = FocusNode(); RawKeyEvent _event; @override @@ -45,23 +45,23 @@ @override Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).textTheme; - return new RawKeyboardListener( + return RawKeyboardListener( focusNode: _focusNode, onKey: _handleKeyEvent, - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: _focusNode, builder: (BuildContext context, Widget child) { if (!_focusNode.hasFocus) { - return new GestureDetector( + return GestureDetector( onTap: () { FocusScope.of(context).requestFocus(_focusNode); }, - child: new Text('Tap to focus', style: textTheme.display1), + child: Text('Tap to focus', style: textTheme.display1), ); } if (_event == null) - return new Text('Press a key', style: textTheme.display1); + return Text('Press a key', style: textTheme.display1); int codePoint; int keyCode; @@ -74,13 +74,13 @@ codePoint = data.codePoint; hidUsage = data.hidUsage; } - return new Column( + return Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ - new Text('${_event.runtimeType}', style: textTheme.body2), - new Text('codePoint: $codePoint', style: textTheme.display4), - new Text('keyCode: $keyCode', style: textTheme.display4), - new Text('hidUsage: $hidUsage', style: textTheme.display4), + Text('${_event.runtimeType}', style: textTheme.body2), + Text('codePoint: $codePoint', style: textTheme.display4), + Text('keyCode: $keyCode', style: textTheme.display4), + Text('hidUsage: $hidUsage', style: textTheme.display4), ], ); },
diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart index f9832dc..938b532 100644 --- a/dev/manual_tests/lib/text.dart +++ b/dev/manual_tests/lib/text.dart
@@ -12,16 +12,16 @@ int seed = 0; void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Text tester', home: const Home(), routes: <String, WidgetBuilder>{ 'underlines': (BuildContext context) => const Underlines(), 'fallback': (BuildContext context) => const Fallback(), 'bidi': (BuildContext context) => const Bidi(), - 'fuzzer': (BuildContext context) => new Fuzzer(seed: seed), - 'zalgo': (BuildContext context) => new Zalgo(seed: seed), - 'painting': (BuildContext context) => new Painting(seed: seed), + 'fuzzer': (BuildContext context) => Fuzzer(seed: seed), + 'zalgo': (BuildContext context) => Zalgo(seed: seed), + 'painting': (BuildContext context) => Painting(seed: seed), }, )); } @@ -30,50 +30,50 @@ const Home({ Key key }) : super(key: key); @override - _HomeState createState() => new _HomeState(); + _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { @override Widget build(BuildContext context) { - return new Material( - child: new Column( + return Material( + child: Column( children: <Widget>[ - new Expanded( - child: new Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ - new FlatButton( + FlatButton( child: const Text('Test Underlines'), color: Colors.red.shade800, textColor: Colors.white, onPressed: () { Navigator.pushNamed(context, 'underlines'); }, ), - new FlatButton( + FlatButton( child: const Text('Test Font Fallback'), color: Colors.orange.shade700, textColor: Colors.white, onPressed: () { Navigator.pushNamed(context, 'fallback'); }, ), - new FlatButton( + FlatButton( child: const Text('Test Bidi Formatting'), color: Colors.yellow.shade700, textColor: Colors.black, onPressed: () { Navigator.pushNamed(context, 'bidi'); }, ), - new FlatButton( + FlatButton( child: const Text('TextSpan Fuzzer'), color: Colors.green.shade400, textColor: Colors.black, onPressed: () { Navigator.pushNamed(context, 'fuzzer'); }, ), - new FlatButton( + FlatButton( child: const Text('Diacritics Fuzzer'), color: Colors.blue.shade400, textColor: Colors.white, onPressed: () { Navigator.pushNamed(context, 'zalgo'); }, ), - new FlatButton( + FlatButton( child: const Text('Painting Fuzzer'), color: Colors.purple.shade200, textColor: Colors.black, @@ -82,9 +82,9 @@ ], ), ), - new Padding( + Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), - child: new Slider( + child: Slider( min: 0.0, max: 1024.0, value: seed.toDouble(), @@ -97,9 +97,9 @@ }, ), ), - new Padding( + Padding( padding: const EdgeInsets.only(bottom: 10.0), - child: new Text('Random seed for fuzzers: $seed'), + child: Text('Random seed for fuzzers: $seed'), ), ], ), @@ -113,7 +113,7 @@ final int seed; @override - _FuzzerState createState() => new _FuzzerState(); + _FuzzerState createState() => _FuzzerState(); } class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin { @@ -124,7 +124,7 @@ @override void initState() { super.initState(); - _random = new math.Random(widget.seed); // providing a seed is important for reproducibility + _random = math.Random(widget.seed); // providing a seed is important for reproducibility _ticker = createTicker(_updateTextSpan)..start(); _updateTextSpan(null); } @@ -142,7 +142,7 @@ } TextSpan _fiddleWith(TextSpan node) { - return new TextSpan( + return TextSpan( text: _fiddleWithText(node.text), style: _fiddleWithStyle(node.style), children: _fiddleWithChildren(node.children?.map((TextSpan child) => _fiddleWith(child))?.toList() ?? <TextSpan>[]), @@ -169,7 +169,7 @@ } if (_random.nextInt(200) == 0) return null; - return new TextStyle( + return TextStyle( color: _fiddleWithColor(style.color), decoration: _fiddleWithDecoration(style.decoration), decorationColor: _fiddleWithColor(style.decorationColor), @@ -224,13 +224,13 @@ case 30: return TextDecoration.overline; case 90: - return new TextDecoration.combine(<TextDecoration>[TextDecoration.underline, TextDecoration.lineThrough]); + return TextDecoration.combine(<TextDecoration>[TextDecoration.underline, TextDecoration.lineThrough]); case 91: - return new TextDecoration.combine(<TextDecoration>[TextDecoration.underline, TextDecoration.overline]); + return TextDecoration.combine(<TextDecoration>[TextDecoration.underline, TextDecoration.overline]); case 92: - return new TextDecoration.combine(<TextDecoration>[TextDecoration.lineThrough, TextDecoration.overline]); + return TextDecoration.combine(<TextDecoration>[TextDecoration.lineThrough, TextDecoration.overline]); case 93: - return new TextDecoration.combine(<TextDecoration>[TextDecoration.underline, TextDecoration.lineThrough, TextDecoration.overline]); + return TextDecoration.combine(<TextDecoration>[TextDecoration.underline, TextDecoration.lineThrough, TextDecoration.overline]); } return null; } @@ -338,7 +338,7 @@ } TextSpan _createRandomTextSpan() { - return new TextSpan( + return TextSpan( text: _createRandomText(), ); } @@ -421,7 +421,7 @@ case 49: return '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𢴈𢵌𢵧𢺳𣲷𤓓𤶸𤷪𥄫𦉘𦟌𦧲𦧺𧨾𨅝𨈇𨋢𨳊𨳍𨳒𩶘'; // http://www.i18nguy.com/unicode/supplementary-test.html case 50: // any random character - return new String.fromCharCode(_random.nextInt(0x10FFFF + 1)); + return String.fromCharCode(_random.nextInt(0x10FFFF + 1)); case 51: return '\u00DF'; // SS case 52: @@ -443,10 +443,10 @@ case 61: // random BMP character case 62: // random BMP character case 63: // random BMP character - return new String.fromCharCode(_random.nextInt(0xFFFF)); + return String.fromCharCode(_random.nextInt(0xFFFF)); case 64: // random emoji case 65: // random emoji - return new String.fromCharCode(0x1F000 + _random.nextInt(0x9FF)); + return String.fromCharCode(0x1F000 + _random.nextInt(0x9FF)); case 66: return 'Z{' + zalgo(_random, _random.nextInt(4) + 2) + '}Z'; case 67: @@ -472,7 +472,7 @@ case 80: case 81: case 82: - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); final int targetLength = _random.nextInt(8) + 1; for (int index = 0; index < targetLength; index += 1) { if (_random.nextInt(20) > 0) { @@ -488,22 +488,22 @@ @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: <Widget>[ - new Expanded( - child: new SingleChildScrollView( - child: new SafeArea( - child: new Padding( + Expanded( + child: SingleChildScrollView( + child: SafeArea( + child: Padding( padding: const EdgeInsets.all(10.0), - child: new RichText(text: _textSpan), + child: RichText(text: _textSpan), ), ), ), ), - new Material( - child: new SwitchListTile( + Material( + child: SwitchListTile( title: const Text('Enable Fuzzer'), value: _ticker.isActive, onChanged: (bool value) { @@ -528,14 +528,14 @@ const Underlines({ Key key }) : super(key: key); @override - _UnderlinesState createState() => new _UnderlinesState(); + _UnderlinesState createState() => _UnderlinesState(); } class _UnderlinesState extends State<Underlines> { String _text = 'i'; - final TextStyle _style = new TextStyle( + final TextStyle _style = TextStyle( inherit: false, color: Colors.yellow.shade200, fontSize: 48.0, @@ -544,12 +544,12 @@ ); Widget _wrap(TextDecorationStyle style) { - return new Align( + return Align( alignment: Alignment.centerLeft, heightFactor: 1.0, - child: new Container( + child: Container( decoration: const BoxDecoration(color: Color(0xFF333333), border: Border(right: BorderSide(color: Colors.white, width: 0.0))), - child: new Text(_text, style: style != null ? _style.copyWith(decoration: TextDecoration.underline, decorationStyle: style) : _style), + child: Text(_text, style: style != null ? _style.copyWith(decoration: TextDecoration.underline, decorationStyle: style) : _style), ), ); } @@ -560,27 +560,27 @@ for (TextDecorationStyle style in TextDecorationStyle.values) lines.add(_wrap(style)); final Size size = MediaQuery.of(context).size; - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: <Widget>[ - new Expanded( - child: new SingleChildScrollView( - child: new Padding( - padding: new EdgeInsets.symmetric( + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric( horizontal: size.width * 0.1, vertical: size.height * 0.1, ), - child: new ListBody( + child: ListBody( children: lines, ) ), ), ), - new Material( - child: new ButtonBar( + Material( + child: ButtonBar( children: <Widget>[ - new FlatButton( + FlatButton( onPressed: () { setState(() { _text += 'i'; @@ -589,7 +589,7 @@ color: Colors.yellow, child: const Text('ADD i'), ), - new FlatButton( + FlatButton( onPressed: () { setState(() { _text += 'w'; @@ -598,7 +598,7 @@ color: Colors.yellow, child: const Text('ADD w'), ), - new FlatButton( + FlatButton( onPressed: _text == '' ? null : () { setState(() { _text = _text.substring(0, _text.length - 1); @@ -621,7 +621,7 @@ const Fallback({ Key key }) : super(key: key); @override - _FallbackState createState() => new _FallbackState(); + _FallbackState createState() => _FallbackState(); } class _FallbackState extends State<Fallback> { @@ -649,23 +649,23 @@ Widget build(BuildContext context) { final List<Widget> lines = <Widget>[]; for (String font in androidFonts) - lines.add(new Text(multiScript, style: style.copyWith(fontFamily: font, fontSize: math.exp(_fontSize)))); + lines.add(Text(multiScript, style: style.copyWith(fontFamily: font, fontSize: math.exp(_fontSize)))); final Size size = MediaQuery.of(context).size; - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: <Widget>[ - new Expanded( - child: new SingleChildScrollView( + Expanded( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: new SingleChildScrollView( - child: new Padding( - padding: new EdgeInsets.symmetric( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric( horizontal: size.width * 0.1, vertical: size.height * 0.1, ), - child: new IntrinsicWidth( - child: new ListBody( + child: IntrinsicWidth( + child: ListBody( children: lines, ), ) @@ -673,18 +673,18 @@ ), ), ), - new Material( - child: new Padding( + Material( + child: Padding( padding: const EdgeInsets.only(left: 20.0, right: 20.0, bottom: 20.0), - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[ const Padding( padding: EdgeInsets.only(bottom: 10.0), child: Text('Font size'), ), - new Expanded( - child: new Slider( + Expanded( + child: Slider( min: 2.0, max: 5.0, value: _fontSize, @@ -710,64 +710,64 @@ const Bidi({ Key key }) : super(key: key); @override - _BidiState createState() => new _BidiState(); + _BidiState createState() => _BidiState(); } class _BidiState extends State<Bidi> { @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.black, - child: new ListView( + child: ListView( padding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 20.0), children: <Widget>[ - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: <TextSpan>[ - new TextSpan(text: 'abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), - new TextSpan(text: 'ghi', style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), - new TextSpan(text: 'mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), - new TextSpan(text: 'LKJ', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), - new TextSpan(text: 'FED', style: new TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), + TextSpan(text: 'abc', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), + TextSpan(text: 'ghi', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), + TextSpan(text: 'mno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), + TextSpan(text: 'LKJ', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), + TextSpan(text: 'FED', style: TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), ], ), textAlign: TextAlign.center, textDirection: TextDirection.ltr, ), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: <TextSpan>[ - new TextSpan(text: '${Unicode.LRO}abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), - new TextSpan(text: '${Unicode.RLO}DEF', style: new TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), - new TextSpan(text: '${Unicode.LRO}ghi', style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), - new TextSpan(text: '${Unicode.RLO}JKL', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), - new TextSpan(text: '${Unicode.LRO}mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), + TextSpan(text: '${Unicode.LRO}abc', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), + TextSpan(text: '${Unicode.RLO}DEF', style: TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), + TextSpan(text: '${Unicode.LRO}ghi', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), + TextSpan(text: '${Unicode.RLO}JKL', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), + TextSpan(text: '${Unicode.LRO}mno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), ], ), textAlign: TextAlign.center, textDirection: TextDirection.ltr, ), const SizedBox(height: 40.0), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: <TextSpan>[ - new TextSpan(text: '${Unicode.LRO}abc${Unicode.RLO}D', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), - new TextSpan(text: 'EF${Unicode.LRO}gh', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), - new TextSpan(text: 'i${Unicode.RLO}JKL${Unicode.LRO}mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + TextSpan(text: '${Unicode.LRO}abc${Unicode.RLO}D', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + TextSpan(text: 'EF${Unicode.LRO}gh', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + TextSpan(text: 'i${Unicode.RLO}JKL${Unicode.LRO}mno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), ], ), textAlign: TextAlign.center, textDirection: TextDirection.ltr, ), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: <TextSpan>[ - new TextSpan(text: 'abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), - new TextSpan(text: 'gh', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), - new TextSpan(text: 'imno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), - new TextSpan(text: 'LKJ', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), - new TextSpan(text: 'FE', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), - new TextSpan(text: 'D', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + TextSpan(text: 'abc', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + TextSpan(text: 'gh', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + TextSpan(text: 'imno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + TextSpan(text: 'LKJ', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + TextSpan(text: 'FE', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + TextSpan(text: 'D', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), ], ), textAlign: TextAlign.center, @@ -787,7 +787,7 @@ final int seed; @override - _ZalgoState createState() => new _ZalgoState(); + _ZalgoState createState() => _ZalgoState(); } class _ZalgoState extends State<Zalgo> with SingleTickerProviderStateMixin { @@ -798,7 +798,7 @@ @override void initState() { super.initState(); - _random = new math.Random(widget.seed); // providing a seed is important for reproducibility + _random = math.Random(widget.seed); // providing a seed is important for reproducibility _ticker = createTicker(_update)..start(); _update(null); } @@ -825,16 +825,16 @@ @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: <Widget>[ - new Expanded( - child: new Center( - child: new RichText( - text: new TextSpan( + Expanded( + child: Center( + child: RichText( + text: TextSpan( text: _text, - style: new TextStyle( + style: TextStyle( inherit: false, fontSize: 96.0, color: Colors.red.shade200, @@ -843,10 +843,10 @@ ), ), ), - new Material( - child: new Column( + Material( + child: Column( children: <Widget>[ - new SwitchListTile( + SwitchListTile( title: const Text('Enable Fuzzer'), value: _ticker.isActive, onChanged: (bool value) { @@ -859,23 +859,23 @@ }); }, ), - new SwitchListTile( + SwitchListTile( title: const Text('Allow spacing combining marks'), value: _allowSpacing, onChanged: (bool value) { setState(() { _allowSpacing = value; - _random = new math.Random(widget.seed); // reset for reproducibility + _random = math.Random(widget.seed); // reset for reproducibility }); }, ), - new SwitchListTile( + SwitchListTile( title: const Text('Vary base character'), value: _varyBase, onChanged: (bool value) { setState(() { _varyBase = value; - _random = new math.Random(widget.seed); // reset for reproducibility + _random = math.Random(widget.seed); // reset for reproducibility }); }, ), @@ -894,7 +894,7 @@ final int seed; @override - _PaintingState createState() => new _PaintingState(); + _PaintingState createState() => _PaintingState(); } class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin { @@ -905,7 +905,7 @@ @override void initState() { super.initState(); - _random = new math.Random(widget.seed); // providing a seed is important for reproducibility + _random = math.Random(widget.seed); // providing a seed is important for reproducibility _ticker = createTicker(_update)..start(); _update(null); } @@ -916,14 +916,14 @@ super.dispose(); } - final GlobalKey intrinsicKey = new GlobalKey(); - final GlobalKey controlKey = new GlobalKey(); + final GlobalKey intrinsicKey = GlobalKey(); + final GlobalKey controlKey = GlobalKey(); bool _ellipsize = false; void _update(Duration duration) { setState(() { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); final int targetLength = _random.nextInt(20) + (_ellipsize ? MediaQuery.of(context).size.width.round() : 1); for (int index = 0; index < targetLength; index += 1) { if (_random.nextInt(5) > 0) { @@ -949,29 +949,29 @@ @override Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ - new Expanded( - child: new Padding( - padding: new EdgeInsets.only(top: size.height * 0.1), - child: new Stack( + Expanded( + child: Padding( + padding: EdgeInsets.only(top: size.height * 0.1), + child: Stack( alignment: Alignment.center, children: <Widget>[ - new Positioned( + Positioned( top: 0.0, left: 0.0, right: 0.0, - child: new Align( + child: Align( alignment: Alignment.topCenter, - child: new IntrinsicWidth( // to test shrink-wrap vs rendering - child: new RichText( + child: IntrinsicWidth( // to test shrink-wrap vs rendering + child: RichText( key: intrinsicKey, textAlign: TextAlign.center, overflow: _ellipsize ? TextOverflow.ellipsis : TextOverflow.clip, - text: new TextSpan( + text: TextSpan( text: _text, style: const TextStyle( inherit: false, @@ -983,15 +983,15 @@ ), ), ), - new Positioned( + Positioned( top: 0.0, left: 0.0, right: 0.0, - child: new RichText( + child: RichText( key: controlKey, textAlign: TextAlign.center, overflow: _ellipsize ? TextOverflow.ellipsis : TextOverflow.clip, - text: new TextSpan( + text: TextSpan( text: _text, style: const TextStyle( inherit: false, @@ -1005,10 +1005,10 @@ ), ), ), - new Material( - child: new Column( + Material( + child: Column( children: <Widget>[ - new SwitchListTile( + SwitchListTile( title: const Text('Enable Fuzzer'), value: _ticker.isActive, onChanged: (bool value) { @@ -1021,13 +1021,13 @@ }); }, ), - new SwitchListTile( + SwitchListTile( title: const Text('Enable Ellipses'), value: _ellipsize, onChanged: (bool value) { setState(() { _ellipsize = value; - _random = new math.Random(widget.seed); // reset for reproducibility + _random = math.Random(widget.seed); // reset for reproducibility if (!_ticker.isActive) _update(null); }); @@ -1036,13 +1036,13 @@ const ListTile( title: Text('There should be no red visible.'), ), - new ButtonBar( + ButtonBar( children: <Widget>[ - new FlatButton( + FlatButton( onPressed: _ticker.isActive ? null : () => _update(null), child: const Text('ITERATE'), ), - new FlatButton( + FlatButton( onPressed: _ticker.isActive ? null : () { print('The currently visible text is: $_text'); print(_text.runes.map((int value) => 'U+${value.toRadixString(16).padLeft(4, '0').toUpperCase()}').join(' ')); @@ -1382,7 +1382,7 @@ 0x16F7E, 0x1D165, 0x1D166, 0x1D16D, 0x1D16E, 0x1D16F, 0x1D170, 0x1D171, 0x1D172, ]; - final Set<int> these = new Set<int>(); + final Set<int> these = Set<int>(); int combiningCount = enclosingCombiningMarks.length + nonspacingCombiningMarks.length; if (includeSpacingCombiningMarks) combiningCount += spacingCombiningMarks.length; @@ -1400,10 +1400,10 @@ } } } - base ??= new String.fromCharCode(randomCharacter(random)); + base ??= String.fromCharCode(randomCharacter(random)); final List<int> characters = <int>[]; characters.addAll(these); - return base + new String.fromCharCodes(characters); + return base + String.fromCharCodes(characters); } T pickFromList<T>(math.Random random, List<T> list) {
diff --git a/dev/manual_tests/test/mock_image_http.dart b/dev/manual_tests/test/mock_image_http.dart index e9708ea..c0ece4c 100644 --- a/dev/manual_tests/test/mock_image_http.dart +++ b/dev/manual_tests/test/mock_image_http.dart
@@ -7,13 +7,13 @@ // Returns a mock HTTP client that responds with an image to all requests. MockHttpClient createMockImageHttpClient(SecurityContext _) { - final MockHttpClient client = new MockHttpClient(); - final MockHttpClientRequest request = new MockHttpClientRequest(); - final MockHttpClientResponse response = new MockHttpClientResponse(); - final MockHttpHeaders headers = new MockHttpHeaders(); - when(client.getUrl(any)).thenAnswer((_) => new Future<HttpClientRequest>.value(request)); + final MockHttpClient client = MockHttpClient(); + final MockHttpClientRequest request = MockHttpClientRequest(); + final MockHttpClientResponse response = MockHttpClientResponse(); + final MockHttpHeaders headers = MockHttpHeaders(); + when(client.getUrl(any)).thenAnswer((_) => Future<HttpClientRequest>.value(request)); when(request.headers).thenReturn(headers); - when(request.close()).thenAnswer((_) => new Future<HttpClientResponse>.value(response)); + when(request.close()).thenAnswer((_) => Future<HttpClientResponse>.value(response)); when(response.contentLength).thenReturn(kTransparentImage.length); when(response.statusCode).thenReturn(HttpStatus.ok); when(response.listen(any)).thenAnswer((Invocation invocation) { @@ -21,7 +21,7 @@ final void Function() onDone = invocation.namedArguments[#onDone]; final void Function(Object, [StackTrace]) onError = invocation.namedArguments[#onError]; final bool cancelOnError = invocation.namedArguments[#cancelOnError]; - return new Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError); + return Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError); }); return client; }
diff --git a/dev/manual_tests/test/overlay_geometry_test.dart b/dev/manual_tests/test/overlay_geometry_test.dart index 5ef9617..6ca3aed 100644 --- a/dev/manual_tests/test/overlay_geometry_test.dart +++ b/dev/manual_tests/test/overlay_geometry_test.dart
@@ -8,7 +8,7 @@ void main() { testWidgets('Overlay geometry smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: new overlay_geometry.OverlayGeometryApp())); + await tester.pumpWidget(MaterialApp(home: overlay_geometry.OverlayGeometryApp())); expect(find.byType(overlay_geometry.Marker), findsNothing); await tester.tap(find.text('Card 3')); await tester.pump();