-
Notifications
You must be signed in to change notification settings - Fork 495
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
刚启动时 .sp 算出来是0 #529
Comments
This issue is stale because it has been open for 30 days with no activity. |
5.9.0问题挺多,但没人回复,奇怪 |
我把你这段代码放到了example中运行,没发现问题啊 |
在release模式下会有问题,调试的时候是没问题的,我把版本换到5.8.4就没问题 |
遇到了,release模式下 |
This issue is stale because it has been open for 30 days with no activity. |
#522 测试可用 |
final TextStyle style = TextStyle( |
I faced the same issue (xx.sp return 0), In my case, this was because I used it in static variables, which try to calculate before screenutil initiated, so my solution Is not to use .sp in static variables instead make a class and initialize one instance from it to be used throw the app, and initiated it in screenutil builder, this fix the issue with me |
you can use this solution for hack 5.9.0 version #558 (comment) |
作者你好,在使用最新版本5.9.0的时候,android release模式下 ,应用刚启动的时候设置 xx.sp,得到的字体大小一直是0,换之前的版本没有这个问题!大致代码如下:
`
class MyHomePageState extends State {
@OverRide
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(360, 690),
minTextAdapt: true,
splitScreenMode: true,
builder: (, child) {
return MaterialApp(
title: 'First Method',
// You can use the library anywhere in the app even in theme
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
),
home: child,
);
},
child: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@OverRide
State createState() => _HomePageState();
}
class _HomePageState extends State {
final TextStyle style = TextStyle(
fontSize: 10.sp,
);
@OverRide
Widget build(BuildContext context) {
print(">>>>>>${style.fontSize}");
return const Center(child: Text("test"));
}
}
`
The text was updated successfully, but these errors were encountered: