mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 20:19:25 +00:00
30 lines
789 B
Dart
30 lines
789 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ResponsiveLayoutUtil {
|
|
static const double _kMobileThreshold = 900;
|
|
|
|
const ResponsiveLayoutUtil._();
|
|
|
|
static final instance = ResponsiveLayoutUtil._();
|
|
|
|
bool isMobile(BuildContext context) {
|
|
final MediaQueryData mediaQueryData = MediaQuery.of(context);
|
|
return mediaQueryData.size.width < _kMobileThreshold;
|
|
}
|
|
|
|
/// Returns dynamic size.
|
|
///
|
|
/// If screen size is mobile, it returns 66% ([scale]) of the [originalValue].
|
|
double getDynamicSize(
|
|
BuildContext context,
|
|
double originalValue, {
|
|
double? mobileSize,
|
|
double? scale,
|
|
}) {
|
|
scale ??= 2 / 3;
|
|
mobileSize ??= originalValue * scale;
|
|
final value = isMobile(context) ? mobileSize : originalValue;
|
|
|
|
return value.roundToDouble();
|
|
}
|
|
}
|