You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
974 B
30 lines
974 B
3 years ago
|
import 'package:flutter/widgets.dart';
|
||
|
|
||
|
class SizeConfig {
|
||
|
static MediaQueryData _mediaQueryData;
|
||
|
static double screenWidth;
|
||
|
static double screenHeight;
|
||
|
static double blockSizeHorizontal;
|
||
|
static double blockSizeVertical;
|
||
|
|
||
|
static double _safeAreaHorizontal;
|
||
|
static double _safeAreaVertical;
|
||
|
static double safeBlockHorizontal;
|
||
|
static double safeBlockVertical;
|
||
|
|
||
|
void init(BuildContext context) {
|
||
|
_mediaQueryData = MediaQuery.of(context);
|
||
|
screenWidth = _mediaQueryData.size.width;
|
||
|
screenHeight = _mediaQueryData.size.height;
|
||
|
blockSizeHorizontal = screenWidth / 100;
|
||
|
blockSizeVertical = screenHeight / 100;
|
||
|
|
||
|
_safeAreaHorizontal =
|
||
|
_mediaQueryData.padding.left + _mediaQueryData.padding.right;
|
||
|
_safeAreaVertical =
|
||
|
_mediaQueryData.padding.top + _mediaQueryData.padding.bottom;
|
||
|
safeBlockHorizontal = (screenWidth - _safeAreaHorizontal) / 100;
|
||
|
safeBlockVertical = (screenHeight - _safeAreaVertical) / 100;
|
||
|
}
|
||
|
}
|