Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defined Size as dp and sp not as percentage. #8

Open
rrifafauzikomara opened this issue Feb 4, 2021 · 2 comments
Open

Defined Size as dp and sp not as percentage. #8

rrifafauzikomara opened this issue Feb 4, 2021 · 2 comments

Comments

@rrifafauzikomara
Copy link

rrifafauzikomara commented Feb 4, 2021

I see your package to defined size is as a percentage (Max to define the size is 100, ex: 100.0.w / 100.0.h --> it's mean the size is 100% / full screen). But can we specify the size is not using a percentage but using a dp for width and height and a sp for the font?

For example, if in the mockup get the size for the font is 14, so we can't implement your package like this:

style: TextStyle(fontSize: 14.0.sp), // This is not sp, but the font size is 14% from the screen. So it not accurate with the size in the mockup that created by designer.

Also if in the mockup get width is 100 and height is 50 for the Button, so we can't implement your package like this:

SizedBox(
   width: 100.0.w,  // This is not accurate with the size in the mockup that created by designer.
   height: 50.0.h, // This is not accurate with the size in the mockup that created by designer.
   child: RaisedButton(),
),

I think this is the major issue.

@huynhphan89
Copy link

@rrifafauzikomara we make an extension like this to work with sizes in the mockup

extension DoubleExt on double {
  static const standardWidth = 1440.0;
  static const standardHeight = 1010.0;

  double textSize() {
    return this * MediaQuery.of(Get.context).size.width / standardWidth;
  }

  double width() {
    return (this / standardWidth * 100).w;
  }

  double height() {
    return (this / standardHeight * 100).h;
  }
}

@zyllus17
Copy link

@rrifafauzikomara we make an extension like this to work with sizes in the mockup

extension DoubleExt on double {
  static const standardWidth = 1440.0;
  static const standardHeight = 1010.0;

  double textSize() {
    return this * MediaQuery.of(Get.context).size.width / standardWidth;
  }

  double width() {
    return (this / standardWidth * 100).w;
  }

  double height() {
    return (this / standardHeight * 100).h;
  }
}

Can you show how to use it and where should I put this extension method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants