getValueForRefinedSize<T> function
T
getValueForRefinedSize<T>({
- required BuildContext context,
- required T normal,
- T? large,
- T? extraLarge,
- T? small,
Will return one of the values passed in for the refined size
Implementation
T getValueForRefinedSize<T>({
required BuildContext context,
required T normal,
T? large,
T? extraLarge,
T? small,
}) {
var refinedSize = getRefinedSize(MediaQuery.of(context).size);
// If we're at extra large size
if (refinedSize == RefinedSize.extraLarge) {
// If we have supplied the extra large layout then display that
if (extraLarge != null) return extraLarge;
// If no extra large layout is supplied we want to check if we have the size below it and display that
if (large != null) return large;
}
if (refinedSize == RefinedSize.large) {
// If we have supplied the large layout then display that
if (large != null) return large;
// If no large layout is supplied we want to check if we have the size below it and display that
if (normal != null) return normal;
}
if (refinedSize == RefinedSize.normal) {
// If we have supplied the normal layout then display that
if (normal != null) return normal;
}
if (refinedSize == RefinedSize.small) {
// If we have supplied the small layout then display that
if (small != null) return small;
}
// If none of the layouts above are supplied or we're on the normal size layout then we show the normal layout
return normal;
}