Skip to content

Instantly share code, notes, and snippets.

@vaygeth89
Created July 3, 2021 13:29
Show Gist options
  • Save vaygeth89/d76cb79ed4656a193432d50ec4ac52f5 to your computer and use it in GitHub Desktop.
Save vaygeth89/d76cb79ed4656a193432d50ec4ac52f5 to your computer and use it in GitHub Desktop.
Flutter Widget with AppBar Wrapper
class WidgetWithAppBarWrapper extends StatelessWidget {
final Widget Function(BuildContext) builder;
const WidgetWithAppBarWrapper({Key? key, required this.builder})
: super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Builder(builder: (context) => builder(context)),
bottomNavigationBar: PersistantBottomAppBar());
}
}
class HomeScreen extends StatelessWidget {
final Widget child;
const HomeScreen({Key? key, required this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return WidgetWithAppBarWrapper(
builder: (
context,
) {
return Center(child: Text("Home Screen"));
},
);
}
}
class DetailsScreen extends StatelessWidget {
const DetailsScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return WidgetWithAppBarWrapper(
builder: (
context,
) {
return Center(child: Text("Detail Screen"));
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment