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

我想在AppTheme 中改主题,不能使用ScreenUtil 的 .w .sp等 #14

Open
Sayidssss opened this issue Dec 4, 2024 · 3 comments
Open

Comments

@Sayidssss
Copy link

请问怎样才能使用呢
我在fontSize后面加了.sp,会报错

appBarTheme: AppBarTheme(
        backgroundColor: Colors.white,
        foregroundColor: Color.fromARGB(200, 0, 0, 0),
        centerTitle: true,
        titleTextStyle: TextStyle(
          fontSize: 18.sp,
          fontWeight: FontWeight.bold,
          color: Color.fromARGB(200, 0, 0, 0),
        ),
      ),
E/flutter (29451): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field '_minTextAdapt@1617084504' has not been initialized.
E/flutter (29451): #0      ScreenUtil._minTextAdapt (package:flutter_screenutil/src/screen_util.dart)
E/flutter (29451): #1      ScreenUtil.scaleText (package:flutter_screenutil/src/screen_util.dart:224:34)
E/flutter (29451): #2      ScreenUtil.setSp (package:flutter_screenutil/src/screen_util.dart:258:65)
E/flutter (29451): #3      SizeExtension.sp (package:flutter_screenutil/src/size_extension.dart:24:33)
E/flutter (29451): #4      AppTheme.light (package:trade_app/common/styles/theme.dart:40:24)
E/flutter (29451): #5      AppTheme.light (package:trade_app/common/styles/theme.dart)
E/flutter (29451): #6      main (package:trade_app/main.dart:57:23)
E/flutter (29451): <asynchronous suspension>
@Kxmrg
Copy link
Owner

Kxmrg commented Dec 4, 2024

AppTheme相关参数的配置是在ScreenUtil初始化之前,无法使用ScreenUtil的相关方法!

@Sayidssss
Copy link
Author

是的,的确是初始化之前, 我想是不是可以等ScreenUtils初始化之后,再去配置APPTheme. 不然Theme中设置的字体大小会跟其他的字体大小不一样

@Kxmrg
Copy link
Owner

Kxmrg commented Dec 4, 2024

复制 lib/common/components/getx_app.dart build方法的相关内容用来替换原来的GetxApp 可以解决掉用顺序的问题

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

2 participants