'Remove debug banner from this specific main.dart

Not sure where to add the: debugShowCheckedModeBanner: false, I'm trying to build for ios with xcode.

Here is the current main.dart:

Not sure what I need to change in order to get this to build. I know it has something to do with MaterialApp but I can't figure out the placement.

`import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:kittscoaching/src/app.dart';
import 'package:kittscoaching/src/resources/theme.dart';

void main() {
  runApp(App());
}


class App extends StatefulWidget {
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  // Set default `_initialized` and `_error` state to false
  bool _initialized = false;
  bool _error = false;

  // Define an async function to initialize FlutterFire
  void initializeFlutterFire() async {
    try {
      // Wait for Firebase to initialize and set `_initialized` state to true
      await Firebase.initializeApp();
      setState(() {
        _initialized = true;
      });
    } catch(e) {
      // Set `_error` state to true if Firebase initialization fails
      setState(() {
        _error = true;
      });
    }
  }

  @override
  void initState() {
    initializeFlutterFire();
    super.initState();
  }


  @override
  Widget build(BuildContext context) {

    // Show error message if initialization failed
    if(_error) {
      //TODO:
      //return SomethingWentWrong();
    }

    // Show a loader until FlutterFire is initialized
    if (!_initialized) {
      // TODO:
      return Container(
        decoration: BoxDecoration(color: KittsTheme.primary),
        child: Center(
          child: Directionality(
              textDirection: TextDirection.ltr,
              child: Text('Loading...')
          )
        )
      );
    }

    return MyApp();
  }
}`


Solution 1:[1]

There isn't a MaterialApp in the code that you're showing. Find the MaterialApp, if there is one, and apply the property there.

Or run your app in release mode: flutter run --release

Or open dev tools and click off the debug banner from there.

Solution 2:[2]

Hope this will help you

    import 'package:firebase_core/firebase_core.dart';
    import 'package:flutter/material.dart';
    import 'package:kittscoaching/src/app.dart';
    import 'package:kittscoaching/src/resources/theme.dart';

    void main() {
      runApp(MyApp());
    }


    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: App(),
          debugShowCheckedModeBanner: false,
        );
      }
    }

    class App extends StatefulWidget {
      _AppState createState() => _AppState();
    }

    class _AppState extends State<App> {
      // Set default `_initialized` and `_error` state to false
      bool _initialized = false;
      bool _error = false;

      // Define an async function to initialize FlutterFire
      void initializeFlutterFire() async {
        try {
          await Firebase.initializeApp();
          setState(() {
            _initialized = true;
          });
        } catch(e) {
          // Set `_error` state to true if Firebase initialization fails
          setState(() {
            _error = true;
          });
        }
      }

      @override
      void initState() {
        initializeFlutterFire();
        super.initState();
      }


      @override
      Widget build(BuildContext context) {

        // Show error message if initialization failed
        if(_error) {
          //TODO:
          //return SomethingWentWrong();
        }

        // Show a loader until FlutterFire is initialized
        if (!_initialized) {
          // TODO:
          return Container(
            decoration: BoxDecoration(color: KittsTheme.primary),
            child: Center(
              child: Directionality(
                  textDirection: TextDirection.ltr,
                  child: Text('Loading...')
              )
            )
          );
        }

        return MyApp();
      }
    }

Solution 3:[3]

Simply you have to specify it in MaterialApp widget. Find the sample code below.

return MaterialApp( debugShowCheckedModeBanner: false, home: SafeArea( ), ),

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lenz
Solution 2 Mohamed Jalal Jalal
Solution 3 Allavudeen S