Commit 2166ea5b authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

apply partially the upcoming unnecessary_lambdas (#8810)

parent f9ad230f
...@@ -430,9 +430,7 @@ Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) { ...@@ -430,9 +430,7 @@ Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) {
Chain.capture(() async { Chain.capture(() async {
await callback(); await callback();
completer.complete(); completer.complete();
}, onError: (dynamic error, Chain chain) async { }, onError: completer.completeError);
completer.completeError(error, chain);
});
return completer.future; return completer.future;
} }
......
...@@ -386,7 +386,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> { ...@@ -386,7 +386,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
backgroundColor: _kAppBackgroundColor, backgroundColor: _kAppBackgroundColor,
body: new Builder( body: new Builder(
// Insert an element so that _buildBody can find the PrimaryScrollController. // Insert an element so that _buildBody can find the PrimaryScrollController.
builder: (BuildContext context) => _buildBody(context), builder: _buildBody,
), ),
); );
} }
......
...@@ -108,9 +108,7 @@ class ShrinePageState extends State<ShrinePage> { ...@@ -108,9 +108,7 @@ class ShrinePageState extends State<ShrinePage> {
new IconButton( new IconButton(
icon: new Icon(Icons.shopping_cart), icon: new Icon(Icons.shopping_cart),
tooltip: 'Shopping cart', tooltip: 'Shopping cart',
onPressed: () { onPressed: _showShoppingCart
_showShoppingCart();
}
), ),
new PopupMenuButton<ShrineAction>( new PopupMenuButton<ShrineAction>(
itemBuilder: (BuildContext context) => <PopupMenuItem<ShrineAction>>[ itemBuilder: (BuildContext context) => <PopupMenuItem<ShrineAction>>[
......
...@@ -183,9 +183,7 @@ class CalculationManager { ...@@ -183,9 +183,7 @@ class CalculationManager {
onProgressListener: (double completed, double total) { onProgressListener: (double completed, double total) {
sender.send(<double>[ completed, total ]); sender.send(<double>[ completed, total ]);
}, },
onResultListener: (String result) { onResultListener: sender.send,
sender.send(result);
},
data: message.data data: message.data
); );
calculator.run(); calculator.run();
......
...@@ -24,7 +24,7 @@ class _NotImplementedDialog extends StatelessWidget { ...@@ -24,7 +24,7 @@ class _NotImplementedDialog extends StatelessWidget {
content: new Text('This feature has not yet been implemented.'), content: new Text('This feature has not yet been implemented.'),
actions: <Widget>[ actions: <Widget>[
new FlatButton( new FlatButton(
onPressed: () { debugDumpApp(); }, onPressed: debugDumpApp,
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Icon( new Icon(
......
...@@ -105,7 +105,7 @@ class StockSettingsState extends State<StockSettings> { ...@@ -105,7 +105,7 @@ class StockSettingsState extends State<StockSettings> {
final List<Widget> rows = <Widget>[ final List<Widget> rows = <Widget>[
new DrawerItem( new DrawerItem(
icon: new Icon(Icons.thumb_up), icon: new Icon(Icons.thumb_up),
onPressed: () => _confirmOptimismChange(), onPressed: _confirmOptimismChange,
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Expanded(child: new Text('Everything is awesome')), new Expanded(child: new Text('Everything is awesome')),
......
...@@ -207,7 +207,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { ...@@ -207,7 +207,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
} }
void _startDoubleTapTimer() { void _startDoubleTapTimer() {
_doubleTapTimer ??= new Timer(kDoubleTapTimeout, () => _reset()); _doubleTapTimer ??= new Timer(kDoubleTapTimeout, _reset);
} }
void _stopDoubleTapTimer() { void _stopDoubleTapTimer() {
......
...@@ -221,9 +221,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr ...@@ -221,9 +221,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
// animations such that their resulting flex values will add up to the desired // animations such that their resulting flex values will add up to the desired
// value. // value.
void _computeWeight() { void _computeWeight() {
final Iterable<Animation<double>> animating = _animations.where( final Iterable<Animation<double>> animating = _animations.where(_isAnimating);
(Animation<double> animation) => _isAnimating(animation)
);
if (animating.isNotEmpty) { if (animating.isNotEmpty) {
final double sum = animating.fold(0.0, (double sum, Animation<double> animation) { final double sum = animating.fold(0.0, (double sum, Animation<double> animation) {
...@@ -246,11 +244,8 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr ...@@ -246,11 +244,8 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
double _xOffset(int index) { double _xOffset(int index) {
double weightSum(Iterable<Animation<double>> animations) { double weightSum(Iterable<Animation<double>> animations) {
return animations.map( // We're adding flex values instead of animation values to have correct ratios.
// We're adding flex values instead of animation values to have correct return animations.map(_flex).fold(0.0, (double sum, double value) => sum + value);
// ratios.
(Animation<double> animation) => _flex(animation)
).fold(0.0, (double sum, double value) => sum + value);
} }
final double allWeights = weightSum(_animations); final double allWeights = weightSum(_animations);
......
...@@ -127,9 +127,7 @@ class _InputFieldState extends State<InputField> { ...@@ -127,9 +127,7 @@ class _InputFieldState extends State<InputField> {
new GestureDetector( new GestureDetector(
key: focusKey == _focusKey ? _focusKey : null, key: focusKey == _focusKey ? _focusKey : null,
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: requestKeyboard,
requestKeyboard();
},
// Since the focusKey may have been created here, defer building the // Since the focusKey may have been created here, defer building the
// EditableText until the focusKey's context has been set. This is // EditableText until the focusKey's context has been set. This is
// necessary because the EditableText will check the focus, like // necessary because the EditableText will check the focus, like
......
...@@ -679,7 +679,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin { ...@@ -679,7 +679,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
_currentBottomSheet = new PersistentBottomSheetController<T>._( _currentBottomSheet = new PersistentBottomSheetController<T>._(
bottomSheet, bottomSheet,
completer, completer,
() => entry.remove(), entry.remove,
(VoidCallback fn) { bottomSheetKey.currentState?.setState(fn); } (VoidCallback fn) { bottomSheetKey.currentState?.setState(fn); }
); );
}); });
......
...@@ -13,8 +13,6 @@ import 'dart:ui' as ui show Image, decodeImageFromList; ...@@ -13,8 +13,6 @@ import 'dart:ui' as ui show Image, decodeImageFromList;
/// resolves to [null]. /// resolves to [null].
Future<ui.Image> decodeImageFromList(Uint8List list) { Future<ui.Image> decodeImageFromList(Uint8List list) {
final Completer<ui.Image> completer = new Completer<ui.Image>(); final Completer<ui.Image> completer = new Completer<ui.Image>();
ui.decodeImageFromList(list, (ui.Image image) { ui.decodeImageFromList(list, completer.complete);
completer.complete(image);
});
return completer.future; return completer.future;
} }
...@@ -52,9 +52,7 @@ void main() { ...@@ -52,9 +52,7 @@ void main() {
final List<double> valueLog = <double>[]; final List<double> valueLog = <double>[];
final List<AnimationStatus> log = <AnimationStatus>[]; final List<AnimationStatus> log = <AnimationStatus>[];
controller controller
..addStatusListener((AnimationStatus status) { ..addStatusListener(log.add)
log.add(status);
})
..addListener(() { ..addListener(() {
valueLog.add(controller.value); valueLog.add(controller.value);
}); });
...@@ -115,9 +113,7 @@ void main() { ...@@ -115,9 +113,7 @@ void main() {
final List<double> valueLog = <double>[]; final List<double> valueLog = <double>[];
final List<AnimationStatus> statusLog = <AnimationStatus>[]; final List<AnimationStatus> statusLog = <AnimationStatus>[];
controller controller
..addStatusListener((AnimationStatus status) { ..addStatusListener(statusLog.add)
statusLog.add(status);
})
..addListener(() { ..addListener(() {
valueLog.add(controller.value); valueLog.add(controller.value);
}); });
...@@ -143,9 +139,7 @@ void main() { ...@@ -143,9 +139,7 @@ void main() {
final List<double> valueLog = <double>[]; final List<double> valueLog = <double>[];
final List<AnimationStatus> statusLog = <AnimationStatus>[]; final List<AnimationStatus> statusLog = <AnimationStatus>[];
controller controller
..addStatusListener((AnimationStatus status) { ..addStatusListener(statusLog.add)
statusLog.add(status);
})
..addListener(() { ..addListener(() {
valueLog.add(controller.value); valueLog.add(controller.value);
}); });
......
...@@ -58,9 +58,7 @@ class TestServiceExtensionsBinding extends BindingBase ...@@ -58,9 +58,7 @@ class TestServiceExtensionsBinding extends BindingBase
Future<Null> flushMicrotasks() { Future<Null> flushMicrotasks() {
final Completer<Null> completer = new Completer<Null>(); final Completer<Null> completer = new Completer<Null>();
new Timer(const Duration(), () { new Timer(const Duration(), completer.complete);
completer.complete();
});
return completer.future; return completer.future;
} }
} }
......
...@@ -41,7 +41,7 @@ void main() { ...@@ -41,7 +41,7 @@ void main() {
); );
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event); _binding.callback = events.add;
ui.window.onPointerDataPacket(packet); ui.window.onPointerDataPacket(packet);
expect(events.length, 2); expect(events.length, 2);
...@@ -59,7 +59,7 @@ void main() { ...@@ -59,7 +59,7 @@ void main() {
); );
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event); _binding.callback = events.add;
ui.window.onPointerDataPacket(packet); ui.window.onPointerDataPacket(packet);
expect(events.length, 3); expect(events.length, 3);
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
); );
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event); _binding.callback = events.add;
ui.window.onPointerDataPacket(packet); ui.window.onPointerDataPacket(packet);
expect(events.length, 3); expect(events.length, 3);
...@@ -104,7 +104,7 @@ void main() { ...@@ -104,7 +104,7 @@ void main() {
); );
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event); _binding.callback = events.add;
ui.window.onPointerDataPacket(packet); ui.window.onPointerDataPacket(packet);
expect(events.length, 2); expect(events.length, 2);
......
...@@ -16,9 +16,7 @@ void main() { ...@@ -16,9 +16,7 @@ void main() {
key: key, key: key,
value: 1, value: 1,
groupValue: 2, groupValue: 2,
onChanged: (int value) { onChanged: log.add,
log.add(value);
},
), ),
), ),
)); ));
...@@ -34,9 +32,7 @@ void main() { ...@@ -34,9 +32,7 @@ void main() {
key: key, key: key,
value: 1, value: 1,
groupValue: 1, groupValue: 1,
onChanged: (int value) { onChanged: log.add,
log.add(value);
},
activeColor: Colors.green[500], activeColor: Colors.green[500],
), ),
), ),
......
...@@ -25,9 +25,7 @@ void main() { ...@@ -25,9 +25,7 @@ void main() {
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return new Container(height: 100.0, child: new Text('Target')); return new Container(height: 100.0, child: new Text('Target'));
}, },
onAccept: (int data) { onAccept: accepted.add
accepted.add(data);
}
), ),
] ]
) )
...@@ -539,9 +537,7 @@ void main() { ...@@ -539,9 +537,7 @@ void main() {
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return new Container(height: 100.0, child: new Text('Target')); return new Container(height: 100.0, child: new Text('Target'));
}, },
onAccept: (int data) { onAccept: accepted.add
accepted.add(data);
}
), ),
] ]
) )
...@@ -731,9 +727,7 @@ void main() { ...@@ -731,9 +727,7 @@ void main() {
) )
); );
}, },
onAccept: (int data) { onAccept: acceptedInts.add
acceptedInts.add(data);
}
), ),
new DragTarget<double>( new DragTarget<double>(
builder: (BuildContext context, List<double> data, List<dynamic> rejects) { builder: (BuildContext context, List<double> data, List<dynamic> rejects) {
...@@ -744,9 +738,7 @@ void main() { ...@@ -744,9 +738,7 @@ void main() {
) )
); );
}, },
onAccept: (double data) { onAccept: acceptedDoubles.add
acceptedDoubles.add(data);
}
), ),
] ]
) )
...@@ -842,9 +834,7 @@ void main() { ...@@ -842,9 +834,7 @@ void main() {
child: new Text('Target1') child: new Text('Target1')
) )
); );
}, onAccept: (DragTargetData data) { }, onAccept: acceptedDragTargetDatas.add
acceptedDragTargetDatas.add(data);
}
), ),
new DragTarget<ExtendedDragTargetData>( new DragTarget<ExtendedDragTargetData>(
builder: (BuildContext context, List<ExtendedDragTargetData> data, List<dynamic> rejects) { builder: (BuildContext context, List<ExtendedDragTargetData> data, List<dynamic> rejects) {
...@@ -855,9 +845,7 @@ void main() { ...@@ -855,9 +845,7 @@ void main() {
) )
); );
}, },
onAccept: (ExtendedDragTargetData data) { onAccept: acceptedExtendedDragTargetDatas.add
acceptedExtendedDragTargetDatas.add(data);
}
), ),
] ]
) )
...@@ -901,9 +889,7 @@ void main() { ...@@ -901,9 +889,7 @@ void main() {
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return new Container(height: 100.0, child: new Text('Target')); return new Container(height: 100.0, child: new Text('Target'));
}, },
onAccept: (int data) { onAccept: accepted.add
accepted.add(data);
}
), ),
] ]
) )
...@@ -1140,9 +1126,7 @@ void main() { ...@@ -1140,9 +1126,7 @@ void main() {
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return new Container(height: 100.0, child: new Text('Target')); return new Container(height: 100.0, child: new Text('Target'));
}, },
onAccept: (int data) { onAccept: accepted.add
accepted.add(data);
}
), ),
] ]
) )
...@@ -1169,9 +1153,7 @@ void main() { ...@@ -1169,9 +1153,7 @@ void main() {
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return new Container(height: 100.0, child: new Text('Target')); return new Container(height: 100.0, child: new Text('Target'));
}, },
onAccept: (int data) { onAccept: accepted.add
accepted.add(data);
}
), ),
] ]
) )
...@@ -1258,9 +1240,7 @@ Future<Null> _testChildAnchorFeedbackPosition({WidgetTester tester, double top: ...@@ -1258,9 +1240,7 @@ Future<Null> _testChildAnchorFeedbackPosition({WidgetTester tester, double top:
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return new Container(height: 100.0, child: new Text('Target')); return new Container(height: 100.0, child: new Text('Target'));
}, },
onAccept: (int data) { onAccept: accepted.add
accepted.add(data);
}
), ),
] ]
) )
......
...@@ -223,9 +223,7 @@ void main() { ...@@ -223,9 +223,7 @@ void main() {
testWidgets('Page changes at halfway point', (WidgetTester tester) async { testWidgets('Page changes at halfway point', (WidgetTester tester) async {
final List<int> log = <int>[]; final List<int> log = <int>[];
await tester.pumpWidget(new PageView( await tester.pumpWidget(new PageView(
onPageChanged: (int page) { onPageChanged: log.add,
log.add(page);
},
children: kStates.map<Widget>((String state) => new Text(state)).toList(), children: kStates.map<Widget>((String state) => new Text(state)).toList(),
)); ));
......
...@@ -28,9 +28,7 @@ void main() { ...@@ -28,9 +28,7 @@ void main() {
await tester.pumpWidget(new RawKeyboardListener( await tester.pumpWidget(new RawKeyboardListener(
focused: true, focused: true,
onKey: (RawKeyEvent event) { onKey: events.add,
events.add(event);
},
child: new Container(), child: new Container(),
)); ));
...@@ -59,9 +57,7 @@ void main() { ...@@ -59,9 +57,7 @@ void main() {
await tester.pumpWidget(new RawKeyboardListener( await tester.pumpWidget(new RawKeyboardListener(
focused: true, focused: true,
onKey: (RawKeyEvent event) { onKey: events.add,
events.add(event);
},
child: new Container(), child: new Container(),
)); ));
......
...@@ -160,7 +160,7 @@ class TimelineSummary { ...@@ -160,7 +160,7 @@ class TimelineSummary {
return durations return durations
.map<double>((Duration duration) => duration.inMilliseconds.toDouble()) .map<double>((Duration duration) => duration.inMilliseconds.toDouble())
.reduce((double a, double b) => math.max(a, b)); .reduce(math.max);
} }
List<TimedEvent> _extractGpuRasterizerDrawEvents() => _extractBeginEndEvents('GPURasterizer::Draw'); List<TimedEvent> _extractGpuRasterizerDrawEvents() => _extractBeginEndEvents('GPURasterizer::Draw');
......
...@@ -889,7 +889,7 @@ class _LiveTestRenderView extends RenderView { ...@@ -889,7 +889,7 @@ class _LiveTestRenderView extends RenderView {
.keys .keys
.where((int pointer) => _pointers[pointer].decay == 0) .where((int pointer) => _pointers[pointer].decay == 0)
.toList() .toList()
.forEach((int pointer) { _pointers.remove(pointer); }); .forEach(_pointers.remove);
if (dirty) if (dirty)
scheduleMicrotask(markNeedsPaint); scheduleMicrotask(markNeedsPaint);
} }
......
...@@ -74,7 +74,7 @@ export 'dart:io' ...@@ -74,7 +74,7 @@ export 'dart:io'
/// Exits the process with the given [exitCode]. /// Exits the process with the given [exitCode].
typedef void ExitFunction(int exitCode); typedef void ExitFunction(int exitCode);
final ExitFunction _defaultExitFunction = (int exitCode) => io.exit(exitCode); final ExitFunction _defaultExitFunction = io.exit;
ExitFunction _exitFunction = _defaultExitFunction; ExitFunction _exitFunction = _defaultExitFunction;
......
...@@ -231,9 +231,7 @@ class MaterialFonts { ...@@ -231,9 +231,7 @@ class MaterialFonts {
).then<Null>((Null value) { ).then<Null>((Null value) {
cache.setStampFor(kName, cache.getVersionFor(kName)); cache.setStampFor(kName, cache.getVersionFor(kName));
status.stop(); status.stop();
}).whenComplete(() { }).whenComplete(status.cancel);
status.cancel();
});
} }
} }
...@@ -376,8 +374,6 @@ class FlutterEngine { ...@@ -376,8 +374,6 @@ class FlutterEngine {
final Status status = logger.startProgress(message, expectSlowOperation: true); final Status status = logger.startProgress(message, expectSlowOperation: true);
return Cache._downloadFileToCache(Uri.parse(url), dest, true).then<Null>((Null value) { return Cache._downloadFileToCache(Uri.parse(url), dest, true).then<Null>((Null value) {
status.stop(); status.stop();
}).whenComplete(() { }).whenComplete(status.cancel);
status.cancel();
});
} }
} }
...@@ -169,7 +169,7 @@ class AnalysisServer { ...@@ -169,7 +169,7 @@ class AnalysisServer {
_process.exitCode.whenComplete(() => _process = null); _process.exitCode.whenComplete(() => _process = null);
final Stream<String> errorStream = _process.stderr.transform(UTF8.decoder).transform(const LineSplitter()); final Stream<String> errorStream = _process.stderr.transform(UTF8.decoder).transform(const LineSplitter());
errorStream.listen((String error) => printError(error)); errorStream.listen(printError);
final Stream<String> inStream = _process.stdout.transform(UTF8.decoder).transform(const LineSplitter()); final Stream<String> inStream = _process.stdout.transform(UTF8.decoder).transform(const LineSplitter());
inStream.listen(_handleServerResponse); inStream.listen(_handleServerResponse);
......
...@@ -88,7 +88,7 @@ class Daemon { ...@@ -88,7 +88,7 @@ class Daemon {
// Start listening. // Start listening.
commandStream.listen( commandStream.listen(
(Map<String, dynamic> request) => _handleRequest(request), _handleRequest,
onDone: () { onDone: () {
if (!_onExitCompleter.isCompleted) if (!_onExitCompleter.isCompleted)
_onExitCompleter.complete(0); _onExitCompleter.complete(0);
...@@ -264,7 +264,7 @@ class DaemonDomain extends Domain { ...@@ -264,7 +264,7 @@ class DaemonDomain extends Domain {
} }
Future<Null> shutdown(Map<String, dynamic> args) { Future<Null> shutdown(Map<String, dynamic> args) {
Timer.run(() => daemon.shutdown()); Timer.run(daemon.shutdown);
return new Future<Null>.value(); return new Future<Null>.value();
} }
......
...@@ -277,7 +277,7 @@ abstract class Device { ...@@ -277,7 +277,7 @@ abstract class Device {
} }
static void printDevices(List<Device> devices) { static void printDevices(List<Device> devices) {
descriptions(devices).forEach((String msg) => printStatus(msg)); descriptions(devices).forEach(printStatus);
} }
} }
......
...@@ -609,9 +609,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader { ...@@ -609,9 +609,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
_IOSSimulatorLogReader(this.device, ApplicationPackage app) { _IOSSimulatorLogReader(this.device, ApplicationPackage app) {
_linesController = new StreamController<String>.broadcast( _linesController = new StreamController<String>.broadcast(
onListen: () { onListen: _start,
_start();
},
onCancel: _stop onCancel: _stop
); );
_appName = app == null ? null : app.name.replaceAll('.app', ''); _appName = app == null ? null : app.name.replaceAll('.app', '');
......
...@@ -230,9 +230,7 @@ abstract class ResidentRunner { ...@@ -230,9 +230,7 @@ abstract class ResidentRunner {
throwToolExit('No Flutter view is available'); throwToolExit('No Flutter view is available');
// Listen for service protocol connection to close. // Listen for service protocol connection to close.
vmService.done.whenComplete(() { vmService.done.whenComplete(appFinished);
appFinished();
});
} }
/// Returns [true] if the input has been handled by this function. /// Returns [true] if the input has been handled by this function.
...@@ -321,9 +319,7 @@ abstract class ResidentRunner { ...@@ -321,9 +319,7 @@ abstract class ResidentRunner {
printHelp(details: false); printHelp(details: false);
} }
terminal.singleCharMode = true; terminal.singleCharMode = true;
terminal.onCharInput.listen((String code) { terminal.onCharInput.listen(processTerminalInput);
processTerminalInput(code);
});
} }
} }
......
...@@ -250,7 +250,7 @@ class FlutterCommandRunner extends CommandRunner<Null> { ...@@ -250,7 +250,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
} }
// The Android SDK could already have been set by tests. // The Android SDK could already have been set by tests.
context.putIfAbsent(AndroidSdk, () => AndroidSdk.locateAndroidSdk()); context.putIfAbsent(AndroidSdk, AndroidSdk.locateAndroidSdk);
if (globalResults['version']) { if (globalResults['version']) {
flutterUsage.sendCommand('version'); flutterUsage.sendCommand('version');
......
...@@ -222,7 +222,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -222,7 +222,7 @@ class _FlutterPlatform extends PlatformPlugin {
processObservatoryPort = detectedPort; processObservatoryPort = detectedPort;
}, },
startTimeoutTimer: () { startTimeoutTimer: () {
new Future<_InitialResult>.delayed(_kTestStartupTimeout, () => timeout.complete()); new Future<_InitialResult>.delayed(_kTestStartupTimeout, timeout.complete);
}, },
); );
...@@ -265,7 +265,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -265,7 +265,7 @@ class _FlutterPlatform extends PlatformPlugin {
final Completer<Null> harnessDone = new Completer<Null>(); final Completer<Null> harnessDone = new Completer<Null>();
final StreamSubscription<dynamic> harnessToTest = controller.stream.listen( final StreamSubscription<dynamic> harnessToTest = controller.stream.listen(
(dynamic event) { testSocket.add(JSON.encode(event)); }, (dynamic event) { testSocket.add(JSON.encode(event)); },
onDone: () { harnessDone.complete(); }, onDone: harnessDone.complete,
onError: (dynamic error, dynamic stack) { onError: (dynamic error, dynamic stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well. // If you reach here, it's unlikely we're going to be able to really handle this well.
printError('test harness controller stream experienced an unexpected error\ntest: $testPath\nerror: $error'); printError('test harness controller stream experienced an unexpected error\ntest: $testPath\nerror: $error');
...@@ -285,7 +285,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -285,7 +285,7 @@ class _FlutterPlatform extends PlatformPlugin {
assert(encodedEvent is String); // we shouldn't ever get binary messages assert(encodedEvent is String); // we shouldn't ever get binary messages
controller.sink.add(JSON.decode(encodedEvent)); controller.sink.add(JSON.decode(encodedEvent));
}, },
onDone: () { testDone.complete(); }, onDone: testDone.complete,
onError: (dynamic error, dynamic stack) { onError: (dynamic error, dynamic stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well. // If you reach here, it's unlikely we're going to be able to really handle this well.
printError('test socket stream experienced an unexpected error\ntest: $testPath\nerror: $error'); printError('test socket stream experienced an unexpected error\ntest: $testPath\nerror: $error');
...@@ -559,9 +559,7 @@ class _FlutterPlatformStreamSinkWrapper<S> implements StreamSink<S> { ...@@ -559,9 +559,7 @@ class _FlutterPlatformStreamSinkWrapper<S> implements StreamSink<S> {
(List<dynamic> value) { (List<dynamic> value) {
_done.complete(); _done.complete();
}, },
onError: (dynamic error, StackTrace stack) { onError: _done.completeError,
_done.completeError(error, stack);
},
); );
return done; return done;
} }
......
...@@ -37,9 +37,7 @@ const Duration kLongRequestTimeout = const Duration(minutes: 1); ...@@ -37,9 +37,7 @@ const Duration kLongRequestTimeout = const Duration(minutes: 1);
class VMService { class VMService {
VMService._(this._peer, this.httpAddress, this.wsAddress, this._requestTimeout) { VMService._(this._peer, this.httpAddress, this.wsAddress, this._requestTimeout) {
_vm = new VM._empty(this); _vm = new VM._empty(this);
_peer.listen().catchError((dynamic e, StackTrace stackTrace) { _peer.listen().catchError(_connectionError.completeError);
_connectionError.completeError(e, stackTrace);
});
_peer.registerMethod('streamNotify', (rpc.Parameters event) { _peer.registerMethod('streamNotify', (rpc.Parameters event) {
_handleStreamNotify(event.asMap); _handleStreamNotify(event.asMap);
...@@ -549,7 +547,7 @@ class VM extends ServiceObjectOwner { ...@@ -549,7 +547,7 @@ class VM extends ServiceObjectOwner {
toRemove.add(id); toRemove.add(id);
} }
}); });
toRemove.forEach((String id) => _isolateCache.remove(id)); toRemove.forEach(_isolateCache.remove);
_buildIsolateList(); _buildIsolateList();
} }
......
...@@ -157,13 +157,8 @@ class _RecordingStream { ...@@ -157,13 +157,8 @@ class _RecordingStream {
_recording.add(new _Response.fromString(element)); _recording.add(new _Response.fromString(element));
_controller.add(element); _controller.add(element);
}, },
onError: (dynamic error, StackTrace stackTrace) { onError: _controller.addError, // We currently don't support recording of errors.
// We currently don't support recording of errors. onDone: _controller.close,
_controller.addError(error, stackTrace);
},
onDone: () {
_controller.close();
},
); );
} }
......
...@@ -51,7 +51,7 @@ void main() { ...@@ -51,7 +51,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.version'}); commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.version'});
...@@ -69,7 +69,7 @@ void main() { ...@@ -69,7 +69,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
printError('daemon.logMessage test'); printError('daemon.logMessage test');
...@@ -95,7 +95,7 @@ void main() { ...@@ -95,7 +95,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
logToStdout: true logToStdout: true
); );
...@@ -115,7 +115,7 @@ void main() { ...@@ -115,7 +115,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'}); commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'});
...@@ -134,7 +134,7 @@ void main() { ...@@ -134,7 +134,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
daemonCommand: command, daemonCommand: command,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
...@@ -155,7 +155,7 @@ void main() { ...@@ -155,7 +155,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
daemonCommand: command, daemonCommand: command,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
...@@ -176,7 +176,7 @@ void main() { ...@@ -176,7 +176,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
daemonCommand: command, daemonCommand: command,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
...@@ -203,7 +203,7 @@ void main() { ...@@ -203,7 +203,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
daemonCommand: command, daemonCommand: command,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
...@@ -221,7 +221,7 @@ void main() { ...@@ -221,7 +221,7 @@ void main() {
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>(); final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
daemon = new Daemon( daemon = new Daemon(
commands.stream, commands.stream,
(Map<String, dynamic> result) => responses.add(result), responses.add,
notifyingLogger: notifyingLogger notifyingLogger: notifyingLogger
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'device.getDevices'}); commands.add(<String, dynamic>{'id': 0, 'method': 'device.getDevices'});
......
...@@ -248,7 +248,7 @@ void main() { ...@@ -248,7 +248,7 @@ void main() {
expect(device.name, 'mock-simulator'); expect(device.name, 'mock-simulator');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
Platform: () => macOsPlatform(), Platform: macOsPlatform,
}); });
testUsingContext('uses existing Android device if and there are no simulators', () async { testUsingContext('uses existing Android device if and there are no simulators', () async {
...@@ -261,7 +261,7 @@ void main() { ...@@ -261,7 +261,7 @@ void main() {
expect(device.name, 'mock-android-device'); expect(device.name, 'mock-android-device');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
Platform: () => macOsPlatform(), Platform: macOsPlatform,
}); });
testUsingContext('launches emulator', () async { testUsingContext('launches emulator', () async {
...@@ -275,7 +275,7 @@ void main() { ...@@ -275,7 +275,7 @@ void main() {
expect(device.name, 'new-simulator'); expect(device.name, 'new-simulator');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
Platform: () => macOsPlatform(), Platform: macOsPlatform,
}); });
}); });
...@@ -288,7 +288,7 @@ void main() { ...@@ -288,7 +288,7 @@ void main() {
expect(await findTargetDevice(), isNull); expect(await findTargetDevice(), isNull);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
Platform: () => platform(), Platform: platform,
}); });
testUsingContext('uses existing Android device', () async { testUsingContext('uses existing Android device', () async {
...@@ -300,7 +300,7 @@ void main() { ...@@ -300,7 +300,7 @@ void main() {
expect(device.name, 'mock-android-device'); expect(device.name, 'mock-android-device');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
Platform: () => platform(), Platform: platform,
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment