Created
July 16, 2025 09:50
-
-
Save shanmugam105/4b420f524e42b80360b818d2fb4501c8 to your computer and use it in GitHub Desktop.
Helper for flutter responsive ui
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
class ResponsiveLayout extends StatelessWidget { | |
final Widget mobileBody; | |
final Widget tabletBody; | |
final Widget desktopBody; | |
ResponsiveLayout({ | |
required this.mobileBody, | |
required this.tabletBody, | |
required this.desktopBody, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return LayoutBuilder( | |
builder: (context, constraints) { | |
if (constraints.maxWidth < 500) { | |
return mobileBody; | |
} else if (constraints.maxWidth < 1100) { | |
return tabletBody; | |
} else { | |
return desktopBody; | |
} | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment