Unverified Commit 9e51cc3e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Add assert for null duration on snackbar (#22746)

parent 8d545e93
......@@ -155,6 +155,7 @@ class SnackBar extends StatelessWidget {
this.duration = _kSnackBarDisplayDuration,
this.animation,
}) : assert(content != null),
assert(duration != null),
super(key: key);
/// The primary content of the snack bar.
......
......@@ -662,4 +662,32 @@ void main() {
expect(find.text('test'), findsNothing);
});
testWidgets('Snackbar asserts if passed a null duration', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target');
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: Builder(
builder: (BuildContext context) {
return GestureDetector(
onTap: () {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(nonconst('hello')),
duration: null,
));
},
behavior: HitTestBehavior.opaque,
child: Container(
height: 100.0,
width: 100.0,
key: tapTarget
),
);
},
),
),
));
await tester.tap(find.byKey(tapTarget));
expect(tester.takeException(), 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