skip to Main Content

enter image description here
here is my code
what to do?

import 'package:flutter/material.dart';
import 'package:hms/screens/login_screen.dart';

void main(List<String> args) {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  MyApp({Key? key})
  // ignore: empty_constructor_bodies
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: LoginScreen(),
      );
  }
}

blank screen in my emulatoer

2

Answers


  1. Here is a working code:

    import 'package:flutter/material.dart';
    import 'package:hms/screens/login_screen.dart';
    
    void main(List<String> args) {
      runApp(MyApp());
    }
    class MyApp extends StatelessWidget {
      MyApp({super.key}); //you forgot the ';' here and you should pass the key to super class
      // ignore: empty_constructor_bodies
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: LoginScreen(),
          );
      }
    }
    
    Login or Signup to reply.
  2. You can fix it through this way:

    class MyApp extends StatelessWidget {
      const MyApp({Key? key})
          : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: LoginScreen(),
        );
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search