OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information

Home Page:https://pub.dartlang.org/packages/flutter_screenutil

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LateInitializationError: Field '_minTextAdapt@1106084504' has not been initialized.

lwx123 opened this issue · comments

MaterialApp中设置theme: lightTheme,

ScreenUtilInit(
designSize: const Size(375, 812),
ensureScreenSize: true,
useInheritedMediaQuery: true,
builder: (BuildContext context, Widget? child){
return child!;
},
child: MaterialApp(
theme: lightTheme,
。。。

var lightTheme = ThemeData(
textTheme:TextTheme(
bodyLarge: TextStyle(fontSize: 16.sp,color: Colors.black87),
bodyMedium: TextStyle(fontSize: 14.sp),
bodySmall: TextStyle(fontSize: 12.sp),
),
);

issues:

======== Exception caught by widgets library =======================================================
The following LateError was thrown building MyApp(dirty, state: _MyAppState#2154d):
LateInitializationError: Field '_minTextAdapt@1106084504' has not been initialized.

The relevant error-causing widget was:
MyApp MyApp:file:///aa/../lib/main.dart:45:16
When the exception was thrown, this was the stack:
#0 ScreenUtil._minTextAdapt (package:flutter_screenutil/src/screen_util.dart)
#1 ScreenUtil.scaleText (package:flutter_screenutil/src/screen_util.dart:208:7)
#2 ScreenUtil.setSp (package:flutter_screenutil/src/screen_util.dart:242:65)
#3 SizeExtension.sp (package:flutter_screenutil/src/size_extension.dart:24:33)
#4 lightTheme (package:remote_guide/theme/app_theme.dart:8:39)
#5 lightTheme (package:remote_guide/theme/app_theme.dart)
#6 _MyAppState.build (package:remote_guide/main.dart:124:24)
#7 StatefulElement.build (package:flutter/src/widgets/framework.dart:5409:27)
#8 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5297:15)
#9 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#10 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#11 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5279:5)
#12 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5453:11)
#13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5273:5)
... Normal element mounting (27 frames)
#40 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4182:16)
#41 Element.updateChild (package:flutter/src/widgets/framework.dart:3707:18)
#42 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1253:16)
#43 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1222:5)
#44 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:1169:18)
#45 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2719:19)
#46 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1168:13)
#47 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:1001:7)
#48 WidgetsBinding.scheduleAttachRootWidget. (package:flutter/src/widgets/binding.dart:981:7)
#52 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
(elided 3 frames from class _Timer and dart:async-patch)

已解决

已解决

咋解决的,刚好遇到了