Last active
December 23, 2023 00:23
-
-
Save owkx/87cb10951e82180419a10b3a5b0d6804 to your computer and use it in GitHub Desktop.
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
// ignore_for_file: prefer_const_constructors | |
// lib/configs | |
import 'package:flutter/material.dart'; | |
final Map<String, WidgetBuilder> routes = { | |
// LayoutScreen.routeName: (context) => LayoutScreen(), | |
}; |
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
// lib/configs/ | |
import 'package:flutter/material.dart'; | |
class SizeConfig { | |
static MediaQueryData _mediaQueryData = const MediaQueryData(); | |
static double screenWidth = 0; | |
static double screenHeight = 0; | |
static double defaultSize = 0; | |
static Orientation orientation = Orientation.landscape; | |
void init(BuildContext context) { | |
_mediaQueryData = MediaQuery.of(context); | |
screenWidth = _mediaQueryData.size.width; | |
screenHeight = _mediaQueryData.size.height; | |
orientation = _mediaQueryData.orientation; | |
} | |
} | |
// Get the proportionate height as per screen size | |
double getProportionateScreenHeight (double inputHeight) { | |
double screenHeight = SizeConfig.screenHeight; | |
// 812 is the lavout height that designer use | |
return (inputHeight / 812.0) * screenHeight; | |
} | |
// Get the proportionate height as per screen size | |
double getProportionateScreenWidth(double inputwidth) { | |
double screenWidth = SizeConfig.screenWidth; | |
// 375 is the lavout width that designer use | |
return (inputwidth / 375.0) * screenWidth; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment