-
Notifications
You must be signed in to change notification settings - Fork 606
/
Copy pathSizeUtil.dart
46 lines (37 loc) · 963 Bytes
/
SizeUtil.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
///
/// Created by NieBin on 2018/12/26
/// Github: https://github.com/nb312
/// Email: niebin312@gmail.com
///
import 'package:flutter/material.dart';
import 'dart:math';
class SizeUtil {
static const _DESIGN_WIDTH = 750;
static const _DESIGN_HEIGHT = 1334;
//logic size in device
static Size _logicSize;
//device pixel radio.
static get width {
return _logicSize.width;
}
static get height {
return _logicSize.height;
}
static set size(size) {
_logicSize = size;
}
//@param w is the design w;
static double getAxisX(double w) {
return (w * width) / _DESIGN_WIDTH;
}
// the y direction
static double getAxisY(double h) {
return (h * height) / _DESIGN_HEIGHT;
}
// diagonal direction value with design size s.
static double getAxisBoth(double s) {
return s *
sqrt((width * width + height * height) /
(_DESIGN_WIDTH * _DESIGN_WIDTH + _DESIGN_HEIGHT * _DESIGN_HEIGHT));
}
}