Closed Ahsan161815 closed 2 years ago
Show me your initialization code or more
Thanks for taking time @lizhuoyuan Here is the main.dart file code
`import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:livescore/constants.dart';
void main() { runApp(SplashScreen()); }
class SplashScreen extends StatelessWidget { const SplashScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( home: ScreenUtilInit( designSize: const Size(375, 820), minTextAdapt: true, builder: () => const Home(), ) ); } }
class Home extends StatelessWidget { const Home({ Key? key, }) : super(key: key);
@override Widget build(BuildContext context) { return Scaffold( backgroundColor: kOther2, body: Padding( padding: EdgeInsets.symmetric(horizontal: 40.w), child: Column( // mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height: 64.h,), Image.asset('assets/images/img.png', width: 291.w, height: 338.11.h,), SizedBox(height: 77.89.h,), Text('Discover all \nabout sport', style: TextStyle( fontSize: 40.sp, color: kWhite, fontFamily: 'SourceSansProS' ), ), SizedBox(height: 14.h,), Text('Search millions of jobs and get the \ninside scoop on companies. \nWWait for what? Let’s get start it!', style: TextStyle( fontSize: 16.sp, color: kGrey2, fontFamily: 'SourceSansProR' ), ), SizedBox(height: 45.h,), SizedBox( width: 199.w, child: ElevatedButton( onPressed: (){}, child: Text('Sign in', style: TextStyle( fontSize: 18.sp, fontFamily: 'SourceSansProS' ), ), style: ElevatedButton.styleFrom( primary: kBlue, padding: EdgeInsets.symmetric(horizontal: 60.w, vertical: 20.h), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.r), ) ), ), ), SizedBox(height: 50.h,), ], ), ), ); } }`
Flutter Doctor Output Here
[√] Flutter (Channel stable, 2.10.1, on Microsoft Windows [Version 10.0.18363.815], locale en-US) • Flutter version 2.10.1 at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision db747aa133 (9 days ago), 2022-02-09 13:57:35 -0600 • Engine revision ab46186b24 • Dart version 2.16.1 • DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at C:\Users\Ahsan\AppData\Local\Android\sdk • Platform android-32, build-tools 32.1.0-rc1 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted.
[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.6) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.0.32126.317 • Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
[√] IntelliJ IDEA Community Edition (version 2021.3) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart
[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.18363.815] • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.102 • Edge (web) • edge • web-javascript • Microsoft Edge 98.0.1108.50
[√] HTTP Host Availability • All required HTTP hosts are available
[√] No issues found!
Show me your initialization code or more
Debug Mode
Release Mode
use ScreenUtil.setContext()
use ScreenUtil.setContext()
Firstly I already Tried That I Copied all the code in flutter_screen_util First Example That didn't work.
After lots of trial and error I solved this issue
When using class based widget Structure may it extends stateless or stateful Widget Android Studio intelisense Shouts to use const modifier when alowed to use const then that widget tree doesnt render at all in release app version if you remove it and let intelisense shout at you then it works fine.
It took me days to figure out.
I don't know if was my mistake, Android Studio or Flutter_Screen_utils.
Something similar happens to me, I worry that my widgets have constant constructors, but it is not possible to use the updates of the heights and widths when my web app resizes, will I have to avoid having constant constructors when using this package?
Something similar happens to me, I worry that my widgets have constant constructors, but it is not possible to use the updates of the heights and widths when my web app resizes, will I have to avoid having constant constructors when using this package?
If it Works
so should delete const
.
builder: (context, widget) { //add this line ScreenUtil.setContext(context); return MediaQuery( //Setting font does not change with system font size data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), child: widget!, ); },
Doesn't work for me, says there is no MediaQuery ancestor
builder: (context, widget) {
//add this line ScreenUtil.setContext(context); return MediaQuery( //Setting font does not change with system font size data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), child: widget!, ); },
You can check #350 for my solution for this problem.
use 5.0.2 version of package, i had use this version in my previous project, this version has no problem, i was fighting with error of non-seen texts in profile or release mode, you should change version in also pubspec.lock
I have tried to solve this issue by changing emulators, Different plugin version, different flutter sdk version, following docs carefully but nothing helped.