-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsize_config.dart
30 lines (25 loc) · 887 Bytes
/
size_config.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import 'package:flutter/material.dart';
/// TODO : just call => SizeConfig.init(context); => in build widget
class SizeConfig {
static BuildContext? appContext;
static MediaQueryData? _mediaQueryData;
static double? screenWidth;
static double? screenHeight;
static Orientation? orientation;
static void init(BuildContext context) {
_mediaQueryData = MediaQuery.of(context);
appContext = context;
screenWidth = _mediaQueryData!.size.width;
screenHeight = _mediaQueryData!.size.height;
orientation = _mediaQueryData!.orientation;
}
static double getHeight(double height) {
return _mediaQueryData!.size.height * (height / 814);
}
static double getWidth(double width) {
return _mediaQueryData!.size.width * (width / 360);
}
static double getTextSize(double textSize) {
return _mediaQueryData!.size.width * (textSize / 414);
}
}