Skip to content

Instantly share code, notes, and snippets.

@richardjharris
Created January 31, 2022 20:39
Show Gist options
  • Save richardjharris/ab2a12442f31b1dd8cc48bc4312733c1 to your computer and use it in GitHub Desktop.
Save richardjharris/ab2a12442f31b1dd8cc48bc4312733c1 to your computer and use it in GitHub Desktop.
/// Widget which pops all open pages except for the root (SearchPage) and
/// sets the query parameters.
class OpenSearchPage extends ConsumerWidget {
final Query query;
const OpenSearchPage({
Key? key,
required this.query,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
WidgetsBinding.instance?.addPostFrameCallback((_) {
Navigator.of(context).popUntil((route) => route.isFirst);
ref.read(searchTextProvider).text = query.text;
ref.read(queryModeProvider.notifier).state = query.mode;
});
return const Spacer();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment