Skip to content

Commit

Permalink
Merge pull request #68 from TahaTesser/pageListBuilder_error_message
Browse files Browse the repository at this point in the history
Throw a helpful error message when returning an empty list in `pageListBuilder`
  • Loading branch information
ulusoyca authored Oct 8, 2023
2 parents f238fab + fb3abba commit 35e451d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/src/wolt_modal_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class _WoltModalSheetState extends State<WoltModalSheet> {
valueListenable: pagesListBuilderNotifier,
builder: (context, pagesBuilder, _) {
final pages = pagesBuilder(context);
assert(pages.isNotEmpty, 'pageListBuilder must return a non-empty list.');
return ValueListenableBuilder<int>(
valueListenable: pageIndexNotifier,
builder: (_, int pageIndex, __) {
Expand Down
4 changes: 3 additions & 1 deletion test/wolt_modal_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ void main() {
await tester.tap(find.text('Open sheet'));
await tester.pumpAndSettle();

expect(tester.takeException(), isNotNull);
final AssertionError exception = tester.takeException() as AssertionError;
expect(exception, isAssertionError);
expect(exception.message, 'pageListBuilder must return a non-empty list.');
});
});

Expand Down

0 comments on commit 35e451d

Please sign in to comment.