Created
May 25, 2022 10:28
-
-
Save saiankit/b1388fd6ff3f45f9d2cc9030faf06d7e to your computer and use it in GitHub Desktop.
Screen Config - 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 'dart:developer'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/widgets.dart'; | |
class SizeConfig { | |
static double _screenWidth = 0; | |
static double _screenHeight = 0; | |
static double _blockWidth = 0; | |
static double _blockHeight = 0; | |
static double textMultiplier = 0; | |
static double imageSizeMultiplier = 0; | |
static double heightMultiplier = 0; | |
static double widthMultiplier = 0; | |
void init(BoxConstraints constraints) { | |
_screenWidth = constraints.maxWidth; | |
_screenHeight = constraints.maxHeight; | |
log('$_screenWidth $_screenHeight'); | |
_blockWidth = _screenWidth / 50.5854791898; | |
_blockHeight = _screenHeight / 112.4121759774; | |
log('$_blockWidth $_blockHeight'); | |
textMultiplier = _blockHeight; | |
imageSizeMultiplier = _blockWidth; | |
heightMultiplier = _blockHeight; | |
widthMultiplier = _blockWidth; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment