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

@@ -36,7 +36,7 @@ class Calculator {
// Run the computation associated with this Calculator.
void run() {
int i = 0;
final JsonDecoder decoder = new JsonDecoder(
final JsonDecoder decoder = JsonDecoder(
(dynamic key, dynamic value) {
if (key is int && i++ % _NOTIFY_INTERVAL == 0)
onProgressListener(i.toDouble(), _NUM_ITEMS.toDouble());
@@ -54,7 +54,7 @@ class Calculator {
}
static String _replicateJson(String data, int count) {
final StringBuffer buffer = new StringBuffer()..write('[');
final StringBuffer buffer = StringBuffer()..write('[');
for (int i = 0; i < count; i++) {
buffer.write(data);
if (i < count - 1)
@@ -88,7 +88,7 @@ class CalculationManager {
CalculationManager({ @required this.onProgressListener, @required this.onResultListener })
: assert(onProgressListener != null),
assert(onResultListener != null),
_receivePort = new ReceivePort() {
_receivePort = ReceivePort() {
_receivePort.listen(_handleMessage);
}
@@ -138,7 +138,7 @@ class CalculationManager {
// loaded.
rootBundle.loadString('services/data.json').then<Null>((String data) {
if (isRunning) {
final CalculationMessage message = new CalculationMessage(data, _receivePort.sendPort);
final CalculationMessage message = CalculationMessage(data, _receivePort.sendPort);
// Spawn an isolate to JSON-parse the file contents. The JSON parsing
// is synchronous, so if done in the main isolate, the UI would block.
Isolate.spawn(_calculate, message).then<Null>((Isolate isolate) {
@@ -178,7 +178,7 @@ class CalculationManager {
// in a separate memory space.
static void _calculate(CalculationMessage message) {
final SendPort sender = message.sendPort;
final Calculator calculator = new Calculator(
final Calculator calculator = Calculator(
onProgressListener: (double completed, double total) {
sender.send(<double>[ completed, total ]);
},
@@ -199,7 +199,7 @@ class CalculationManager {
// the AnimationController for the running animation.
class IsolateExampleWidget extends StatefulWidget {
@override
IsolateExampleState createState() => new IsolateExampleState();
IsolateExampleState createState() => IsolateExampleState();
}
// Main application state.
@@ -215,11 +215,11 @@ class IsolateExampleState extends State<StatefulWidget> with SingleTickerProvide
@override
void initState() {
super.initState();
_animation = new AnimationController(
_animation = AnimationController(
duration: const Duration(milliseconds: 3600),
vsync: this,
)..repeat();
_calculationManager = new CalculationManager(
_calculationManager = CalculationManager(
onProgressListener: _handleProgressUpdate,
onResultListener: _handleResult
);
@@ -233,32 +233,32 @@ class IsolateExampleState extends State<StatefulWidget> with SingleTickerProvide
@override
Widget build(BuildContext context) {
return new Material(
child: new Column(
return Material(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new RotationTransition(
RotationTransition(
turns: _animation,
child: new Container(
child: Container(
width: 120.0,
height: 120.0,
color: const Color(0xFF882222),
)
),
new Opacity(
Opacity(
opacity: _calculationManager.isRunning ? 1.0 : 0.0,
child: new CircularProgressIndicator(
child: CircularProgressIndicator(
value: _progress
)
),
new Text(_status),
new Center(
child: new RaisedButton(
child: new Text(_label),
Text(_status),
Center(
child: RaisedButton(
child: Text(_label),
onPressed: _handleButtonPressed
)
),
new Text(_result)
Text(_result)
]
)
);
@@ -303,5 +303,5 @@ class IsolateExampleState extends State<StatefulWidget> with SingleTickerProvide
}
void main() {
runApp(new MaterialApp(home: new IsolateExampleWidget()));
runApp(MaterialApp(home: IsolateExampleWidget()));
}

View File

@@ -8,7 +8,7 @@ class LifecycleWatcher extends StatefulWidget {
const LifecycleWatcher({ Key key }) : super(key: key);
@override
_LifecycleWatcherState createState() => new _LifecycleWatcherState();
_LifecycleWatcherState createState() => _LifecycleWatcherState();
}
class _LifecycleWatcherState extends State<LifecycleWatcher>
@@ -38,7 +38,7 @@ class _LifecycleWatcherState extends State<LifecycleWatcher>
Widget build(BuildContext context) {
if (_lastLifecycleState == null)
return const Text('This widget has not observed any lifecycle changes.');
return new Text('The most recent lifecycle state this widget observed was: $_lastLifecycleState.');
return Text('The most recent lifecycle state this widget observed was: $_lastLifecycleState.');
}
}