feat : PopScope and there logic
This commit is contained in:
@@ -23,11 +23,10 @@ class BasePage extends StatefulWidget {
|
||||
this.onFilterTap,
|
||||
this.onSearchTap,
|
||||
this.filteringWidget,
|
||||
}):assert(
|
||||
(routes != null ) || routesWidget != null,
|
||||
'Either routes or routesWidget must be provided.',
|
||||
);
|
||||
|
||||
}) : assert(
|
||||
(routes != null) || routesWidget != null,
|
||||
'Either routes or routesWidget must be provided.',
|
||||
);
|
||||
|
||||
final List<String>? routes;
|
||||
final Widget? routesWidget;
|
||||
@@ -77,29 +76,33 @@ class _BasePageState extends State<BasePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.bgLight,
|
||||
appBar: chickenAppBar(
|
||||
hasBack: widget.isBase ? false : widget.hasBack,
|
||||
onBackPressed: widget.onBackPressed,
|
||||
hasFilter: widget.hasFilter,
|
||||
hasSearch: widget.hasSearch,
|
||||
isBase: widget.isBase,
|
||||
onFilterTap: widget.hasFilter ? () => controller.toggleFilter() : null,
|
||||
onSearchTap: widget.hasSearch ? () => Get.find<SearchLogic>().toggleSearch() : null,
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, result) => widget.onBackPressed,
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColor.bgLight,
|
||||
appBar: chickenAppBar(
|
||||
hasBack: widget.isBase ? false : widget.hasBack,
|
||||
onBackPressed: widget.onBackPressed,
|
||||
hasFilter: widget.hasFilter,
|
||||
hasSearch: widget.hasSearch,
|
||||
isBase: widget.isBase,
|
||||
onFilterTap: widget.hasFilter ? () => controller.toggleFilter() : null,
|
||||
onSearchTap: widget.hasSearch ? () => Get.find<SearchLogic>().toggleSearch() : null,
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!),
|
||||
if (!widget.isBase && widget.hasSearch) ...{
|
||||
SearchWidget(onSearchChanged: widget.onSearchChanged),
|
||||
},
|
||||
...widget.widgets,
|
||||
],
|
||||
),
|
||||
floatingActionButtonLocation: widget.floatingActionButtonLocation,
|
||||
floatingActionButton: widget.floatingActionButton,
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!),
|
||||
if (!widget.isBase && widget.hasSearch) ...{
|
||||
SearchWidget(onSearchChanged: widget.onSearchChanged),
|
||||
},
|
||||
...widget.widgets,
|
||||
],
|
||||
),
|
||||
floatingActionButtonLocation: widget.floatingActionButtonLocation,
|
||||
floatingActionButton: widget.floatingActionButton,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user