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

@@ -23,7 +23,7 @@ const MethodChannel kSemanticsChannel = MethodChannel('semantics');
Future<String> dataHandler(String message) async {
if (message.contains('getSemanticsNode')) {
final Completer<String> completer = new Completer<String>();
final Completer<String> completer = Completer<String>();
final int id = int.tryParse(message.split('#')[1]) ?? 0;
Future<void> completeSemantics([Object _]) async {
final dynamic result = await kSemanticsChannel.invokeMethod('getSemanticsNode', <String, dynamic>{
@@ -37,7 +37,7 @@ Future<String> dataHandler(String message) async {
completeSemantics();
return completer.future;
}
throw new UnimplementedError();
throw UnimplementedError();
}
const List<String> routes = <String>[
@@ -50,18 +50,18 @@ class TestApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
routes: <String, WidgetBuilder>{
selectionControlsRoute: (BuildContext context) => new SelectionControlsPage(),
textFieldRoute: (BuildContext context) => new TextFieldPage(),
selectionControlsRoute: (BuildContext context) => SelectionControlsPage(),
textFieldRoute: (BuildContext context) => TextFieldPage(),
},
home: new Builder(
home: Builder(
builder: (BuildContext context) {
return new Scaffold(
body: new ListView(
return Scaffold(
body: ListView(
children: routes.map((String value) {
return new MaterialButton(
child: new Text(value),
return MaterialButton(
child: Text(value),
onPressed: () {
Navigator.of(context).pushNamed(value);
},

View File

@@ -51,7 +51,7 @@ class AndroidSemanticsNode {
/// ]
/// }
factory AndroidSemanticsNode.deserialize(String value) {
return new AndroidSemanticsNode._(json.decode(value));
return AndroidSemanticsNode._(json.decode(value));
}
final Map<String, Object> _values;
@@ -129,7 +129,7 @@ class AndroidSemanticsNode {
Rect getRect() {
final Map<String, Object> rawRect = _values['rect'];
final Map<String, int> rect = rawRect.cast<String, int>();
return new Rect.fromLTRB(
return Rect.fromLTRB(
rect['left'].toDouble(),
rect['top'].toDouble(),
rect['right'].toDouble(),
@@ -140,7 +140,7 @@ class AndroidSemanticsNode {
/// Gets a [Size] which defines the size of the semantics node.
Size getSize() {
final Rect rect = getRect();
return new Size(rect.bottom - rect.top, rect.right - rect.left);
return Size(rect.bottom - rect.top, rect.right - rect.left);
}
/// Gets a list of [AndroidSemanticsActions] which are defined for the node.

View File

@@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher;
export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
/// A matcher that compares the type of the actual value to the type argument T.
Matcher isInstanceOf<T>() => new test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544

View File

@@ -31,7 +31,7 @@ Matcher hasAndroidSemantics({
bool isPassword,
bool isLongClickable,
}) {
return new _AndroidSemanticsMatcher(
return _AndroidSemanticsMatcher(
text: text,
contentDescription: contentDescription,
className: className,

View File

@@ -11,7 +11,7 @@ export 'controls_constants.dart';
/// A test page with a checkbox, three radio buttons, and a switch.
class SelectionControlsPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _SelectionControlsPageState();
State<StatefulWidget> createState() => _SelectionControlsPageState();
}
class _SelectionControlsPageState extends State<SelectionControlsPage> {
@@ -53,13 +53,13 @@ class _SelectionControlsPageState extends State<SelectionControlsPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: new Material(
child: new Column(children: <Widget>[
new Row(
return Scaffold(
appBar: AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: Material(
child: Column(children: <Widget>[
Row(
children: <Widget>[
new Checkbox(
Checkbox(
key: checkbox1Key,
value: _isChecked,
onChanged: _updateCheckbox,
@@ -72,23 +72,23 @@ class _SelectionControlsPageState extends State<SelectionControlsPage> {
],
),
const Spacer(),
new Row(children: <Widget>[
new Radio<int>(key: radio1Key, value: 0, groupValue: _radio, onChanged: _updateRadio),
new Radio<int>(key: radio2Key, value: 1, groupValue: _radio, onChanged: _updateRadio),
new Radio<int>(key: radio3Key, value: 2, groupValue: _radio, onChanged: _updateRadio),
Row(children: <Widget>[
Radio<int>(key: radio1Key, value: 0, groupValue: _radio, onChanged: _updateRadio),
Radio<int>(key: radio2Key, value: 1, groupValue: _radio, onChanged: _updateRadio),
Radio<int>(key: radio3Key, value: 2, groupValue: _radio, onChanged: _updateRadio),
]),
const Spacer(),
new Switch(
Switch(
key: switchKey,
value: _isOn,
onChanged: _updateSwitch,
),
const Spacer(),
new MergeSemantics(
child: new Row(
MergeSemantics(
child: Row(
children: <Widget>[
const Text(switchLabel),
new Switch(
Switch(
key: labeledSwitchKey,
value: _isLabeledOn,
onChanged: _updateLabeledSwitch,

View File

@@ -11,28 +11,28 @@ export 'text_field_constants.dart';
/// A page with a normal text field and a password field.
class TextFieldPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _TextFieldPageState();
State<StatefulWidget> createState() => _TextFieldPageState();
}
class _TextFieldPageState extends State<TextFieldPage> {
final TextEditingController _normalController = new TextEditingController();
final TextEditingController _passwordController = new TextEditingController();
final TextEditingController _normalController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final Key normalTextFieldKey = const ValueKey<String>(normalTextFieldKeyValue);
final Key passwordTextFieldKey = const ValueKey<String>(passwordTextFieldKeyValue);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: new Material(
child: new Column(children: <Widget>[
new TextField(
return Scaffold(
appBar: AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: Material(
child: Column(children: <Widget>[
TextField(
key: normalTextFieldKey,
controller: _normalController,
autofocus: false,
),
const Spacer(),
new TextField(
TextField(
key: passwordTextFieldKey,
controller: _passwordController,
obscureText: true,

View File

@@ -17,7 +17,7 @@ void main() {
Future<AndroidSemanticsNode> getSemantics(SerializableFinder finder) async {
final int id = await driver.getSemanticsId(finder);
final String data = await driver.requestData('getSemanticsNode#$id');
return new AndroidSemanticsNode.deserialize(data);
return AndroidSemanticsNode.deserialize(data);
}
setUpAll(() async {