Created
December 21, 2022 01:49
-
-
Save Calpoog/93da2cb54e048c2af994b2739296723e to your computer and use it in GitHub Desktop.
Using responsive_toolkit
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
@override | |
Widget build(BuildContext context) { | |
final cardBreakpoints = Breakpoints( | |
xs: const ResponsiveColumnConfig(span: 12), | |
md: const ResponsiveColumnConfig(span: 6), | |
lg: const ResponsiveColumnConfig(span: 3), | |
); | |
final containerMaxWidth = ResponsiveLayout.value( | |
context, | |
Breakpoints( | |
xs: const BoxConstraints(), | |
lg: const BoxConstraints.tightFor(width: 960), | |
xl: const BoxConstraints.tightFor(width: 1140), | |
xxl: const BoxConstraints.tightFor(width: 1320), | |
), | |
); | |
final textTheme = Theme.of(context).textTheme; | |
final headlineStyle = ResponsiveLayout.value( | |
context, | |
Breakpoints( | |
xs: textTheme.titleLarge, | |
md: textTheme.displaySmall, | |
lg: textTheme.displayMedium, | |
xl: textTheme.displayLarge, | |
), | |
); | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Library'), | |
), | |
body: SingleChildScrollView( | |
padding: const EdgeInsets.all(20), | |
child: Align( | |
alignment: Alignment.topCenter, | |
child: ConstrainedBox( | |
constraints: containerMaxWidth, | |
child: Column( | |
children: [ | |
Text( | |
'Heading', | |
style: headlineStyle, | |
), | |
gap, | |
ResponsiveRow( | |
runSpacing: 20.0, | |
spacing: 20.0, | |
columns: [ | |
ResponsiveColumn(cardBreakpoints, child: card1), | |
ResponsiveColumn(cardBreakpoints, child: card2), | |
ResponsiveColumn(cardBreakpoints, child: card3), | |
ResponsiveColumn(cardBreakpoints, child: card4), | |
], | |
), | |
], | |
), | |
), | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment