Created
July 3, 2021 13:29
-
-
Save vaygeth89/d76cb79ed4656a193432d50ec4ac52f5 to your computer and use it in GitHub Desktop.
Flutter Widget with AppBar Wrapper
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
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