Skip to content

Instantly share code, notes, and snippets.

@alperefesahin
Created February 6, 2023 19:09
Show Gist options
  • Save alperefesahin/318584093cc2095c2927986f7449cdd0 to your computer and use it in GitHub Desktop.
Save alperefesahin/318584093cc2095c2927986f7449cdd0 to your computer and use it in GitHub Desktop.
class ResponsiveLayout extends StatelessWidget {
const ResponsiveLayout({
super.key,
required this.mobileLayout,
required this.desktopLayout,
});
final Widget mobileLayout;
final Widget desktopLayout;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth < 768) {
return mobileLayout;
} else {
return desktopLayout;
}
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment