OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
https://pub.dartlang.org/packages/flutter_screenutil
Apache License 2.0
3.88k stars 497 forks source link

The following _TypeError was thrown building SplashScreen(dirty): Null check operator used on a null value #531

Closed kpohMarfo closed 9 months ago

kpohMarfo commented 11 months ago

The relevant error-causing widget was: SplashScreen SplashScreen:file:///D:/chat-support/recreate-1/lib/main.dart:46:43

Main.dart `import 'package:chatapp/app/controllers/auth_controller.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart';

import 'app/routes/app_pages.dart'; import 'app/utils/splash_screen.dart';

void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); await GetStorage.init(); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) .then((value) => runApp(MyApp())); }

class MyApp extends StatelessWidget { final authC = Get.put(AuthController(), permanent: true);

@override Widget build(BuildContext context) { return FutureBuilder( future: Future.delayed(Duration(seconds: 2)), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { return Obx( () => GetMaterialApp( title: "ChatApp", theme: ThemeData( brightness: Brightness.light, primaryColor: Colors.white, colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.black), ), initialRoute: authC.isSkipIntro.isTrue ? authC.isAuth.isTrue ? Routes.HOME : Routes.LOGIN : Routes.INTRODUCTION, getPages: AppPages.routes, ), ); } return FutureBuilder( future: authC.firstInitialized(), builder: (context, snapshot) => SplashScreen(), ); }, ); } } `

splashscreen.dart `import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:get/get.dart';

class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: Container( width: Get.width 0.75, height: Get.width 0.75, child: Lottie.asset("assets/lottie/hello.json"), ), ), ), ); } } `

github-actions[bot] commented 10 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 9 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.