Fixed Empty Search Field Bug

This commit is contained in:
Basit Ali
2023-09-12 02:11:19 +05:00
parent a6775b95a9
commit ed8a6e01e9

View File

@ -10,15 +10,24 @@ import 'package:openlib/state/state.dart'
typeValues, typeValues,
sortValues; sortValues;
import 'components/snack_bar_widget.dart';
class SearchPage extends ConsumerWidget { class SearchPage extends ConsumerWidget {
const SearchPage({Key? key}) : super(key: key); const SearchPage({Key? key}) : super(key: key);
void onSubmit(BuildContext context, WidgetRef ref) { void onSubmit(BuildContext context, WidgetRef ref) {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { if(ref.read(searchQueryProvider).isNotEmpty) {
Navigator.push(
context, MaterialPageRoute(builder: (BuildContext context) {
return ResultPage( return ResultPage(
searchQuery: ref.read(searchQueryProvider), searchQuery: ref.read(searchQueryProvider),
); );
})); }
));
}
else{
showSnackBar(context: context, message: 'Search field is empty');
}
} }
@override @override