Created
January 31, 2022 20:39
-
-
Save richardjharris/ab2a12442f31b1dd8cc48bc4312733c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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