A package to handle and empower responsive development patterns with the help of custom widgets and extension functions.
Custom widget and extension methods to make working with device orientation possible.
- Takes in a landscapeChild
- Takes in a portraitChild
- Builds the correct child depending on the device orientation
ResponsiveByOrientation(
landscapeChild: landScapeChild,
portraitChild: portraitChild,
);
Extension functions for concise access to ResponsiveByOrientation
// Custom Widget Equivalent
ResponsiveByOrientation(
landscapeChild: landScapeChild,
portraitChild: portraitChild,
);
// extension 1
portraitChild.whenOrientationLandscape(landScapeChild);
// extension 2
landscapeChild.whenOrientationPortrait(portraitChild);
- Works on values of any type.
- Takes
portraitValue
,landscapeValue
andBuildContext
- Returns the correct value using
MediaQuery
internally and exposes it on thevalue
getter
Text(
ValueByOrientation(
"landscapeText",
"portraitText",
context,
).value,
),
can also be extended to other values and types, as exemplified in the extension functions.
Extension functions on Object
allowing this to be available for any type and make available ValueByOrientation
class with defaults.
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4.copyWith(
fontSize: 34.0.valueWhenOrientaitonLandscape(
context,
21.0,
),
),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4.copyWith(
fontSize: 34.0.valueWhenOrientaitonPortrait(
context,
21.0,
),
),
),