Using dimens in font size as design

165 Views Asked by At

enter image description here

I want to create a text base TextStyle to apply the image above, but I read some suggestions related to dimes then they advise me to use flutter_screenutil 5.0.3 package.

But it got errors:

LateInitializationError: Field '\_minTextAdapt@647084504' has not been initialized.

Also using this library I'm not sure it can define the screen well when rotating the screen horizontally.

My code in app_theme.dart:

class AppText extends TextStyle {
  static TextStyle get text12 => TextStyle(
        // TODO this has an error when I using library dimens
        fontSize: 12.sp,
        fontFamily: Platform.isIOS ? Fonts.avenirNextRegular : Fonts.robotoRegular,
        fontWeight: FontWeight.normal,
        color: AppColor.mineShaft,
      );

  static TextStyle get text13 => TextStyle(
        fontSize: 13,
        fontFamily: Platform.isIOS ? Fonts.avenirNextRegular : Fonts.robotoRegular,
        fontWeight: FontWeight.normal,
        color: AppColor.mineShaft,
      );

  static TextStyle get text16 => TextStyle(
        fontSize: 16,
        fontFamily: Platform.isIOS ? Fonts.avenirNextRegular : Fonts.robotoRegular,
        fontWeight: FontWeight.normal,
        color: AppColor.mineShaft,
      );

  static TextStyle get text18 => TextStyle(
        fontSize: 18,
        fontFamily: Platform.isIOS ? Fonts.avenirNextRegular : Fonts.robotoRegular,
        fontWeight: FontWeight.normal,
        color: AppColor.mineShaft,
      );

  static TextStyle get text20 => TextStyle(
        fontSize: 20,
        fontFamily: Platform.isIOS ? Fonts.avenirNextRegular : Fonts.robotoRegular,
        fontWeight: FontWeight.normal,
        color: AppColor.mineShaft,
      );

  static TextStyle get text22 => TextStyle(
        fontSize: 22,
        fontFamily: Platform.isIOS ? Fonts.avenirNextRegular : Fonts.robotoRegular,
        fontWeight: FontWeight.normal,
        color: AppColor.mineShaft,
      );
}

How can I create base fontSize text and apply it to dimens app text according to the design font above?

0

There are 0 best solutions below