Created
June 18, 2020 13:44
-
-
Save marcos-bah/62e2f507a1861f9a640c5f757d3ce9bb to your computer and use it in GitHub Desktop.
Classe para posicionar elementos no Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment