I am working on a flutter application and using the screen util package ScreenUtil, but the app gives me an error when using the child attribute to insert the Material app widget. Here is my code:`
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:spoon_app/screens/splash_screen/mobile.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const Spoon());
}
class Spoon extends StatelessWidget {
const Spoon({super.key});
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(375, 812),
minTextAdapt: true,
splitScreenMode: true,
// when to use the child attribute it yields with an error
child: MaterialApp(
theme: ThemeData(
scaffoldBackgroundColor: const Color(0XFFFFFFFF),
textTheme: TextTheme(
bodySmall: TextStyle(
fontSize: 14.sp,
fontFamily: "Alex",
fontWeight: FontWeight.w400,
height: 1.3.h,
),
bodyMedium: TextStyle(
fontSize: 12.sp,
fontFamily: "Alex",
fontWeight: FontWeight.w700,
),
bodyLarge: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: "Alex",
fontWeight: FontWeight.w700,
),
headlineMedium: const TextStyle(
fontSize: 32,
fontWeight: FontWeight.w500,
),
headlineLarge: TextStyle(
fontFamily: "Alex",
fontSize: 32.sp,
fontWeight: FontWeight.w500,
)),
),
debugShowCheckedModeBanner: false,
title: "SpoonApp",
home: MobileWelcomeScreen(),
),
);
}
}
`
in a speedy manner, am I in much need for a fix for my problem.
2
Answers
Try to use builder and child attribute like this:
Please add this parameter, minTextAdapt: true, // Here, provide a value for minTextAdapt