Commit 67367974 authored by Adam Barth's avatar Adam Barth

Merge pull request #1538 from abarth/fix_snackbar

SnackBar throws exception on creation
parents 09d26302 6b1c85a8
...@@ -245,6 +245,10 @@ abstract class Route { ...@@ -245,6 +245,10 @@ abstract class Route {
} }
abstract class PerformanceRoute extends Route { abstract class PerformanceRoute extends Route {
PerformanceRoute() {
_performance = createPerformance();
}
PerformanceView get performance => _performance?.view; PerformanceView get performance => _performance?.view;
Performance _performance; Performance _performance;
...@@ -261,7 +265,6 @@ abstract class PerformanceRoute extends Route { ...@@ -261,7 +265,6 @@ abstract class PerformanceRoute extends Route {
Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance); Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance);
void didPush(NavigatorState navigator) { void didPush(NavigatorState navigator) {
_performance = createPerformance();
super.didPush(navigator); super.didPush(navigator);
_performance?.forward(); _performance?.forward();
} }
......
import 'package:sky/widgets.dart';
import 'package:test/test.dart';
import 'widget_tester.dart';
void main() {
test('SnackBar control test', () {
testWidgets((WidgetTester tester) {
String helloSnackBar = 'Hello SnackBar';
GlobalKey<PlaceholderState> placeholderKey = new GlobalKey<PlaceholderState>();
Key tapTarget = new Key('tap-target');
tester.pumpWidget(new App(
routes: {
'/': (RouteArguments args) {
return new GestureDetector(
onTap: () {
showSnackBar(
navigator: args.navigator,
placeholderKey: placeholderKey,
content: new Text(helloSnackBar)
);
},
child: new Center(
key: tapTarget,
child: new Placeholder(key: placeholderKey)
)
);
}
}
));
tester.tap(tester.findElementByKey(tapTarget));
expect(tester.findText(helloSnackBar), isNull);
tester.pump();
expect(tester.findText(helloSnackBar), isNotNull);
});
});
}
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