5

I'm trying to remove the debug banner from my application and I added debugShowCheckedModeBanner: false in my main.dart and every activity but still showing the debug banner.

Main.dart

void main() async {

  runApp(MaterialApp(home:SplashScreen(), debugShowCheckedModeBanner: false,));

}

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => new _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
 

  startTime() async {
    var _duration = new Duration(seconds: 1);
    return new Timer(_duration, navigationPage);
  }

  void navigationPage() {
    Navigator.pushReplacement(
        context,
        new CupertinoPageRoute(
            builder: (BuildContext context) => MyHomesApp()));

  }



  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Stack(
        children: <Widget>[
          Container(
            decoration: new BoxDecoration(color: colorGreen),
          ),
          Container(
            padding: EdgeInsets.all(30.0),
            child: Center(
              child: new Image.asset('assets/green_h_logo.png',color: Colors.white,height: 150,width: 150,)
            ),
          ),
          Align(
            alignment: Alignment.bottomCenter,
            child: Container(
                height: 50,
                child:new Image.asset('assets/h.gif')),
          ),
        ],
      ),
    );
  }
} 

The above code is my main.dart, it loads a splash screen and after a second it navigates to myhomesapp which has bottomnavigationbar as below:

home.dart

class MyHomesApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return MaterialApp(

      debugShowCheckedModeBanner: false,

      title: 'App Name',
      theme: ThemeData(
        primarySwatch: Colors.green,
        fontFamily: "Montserrat", //my custom font
      ),
      builder: (context, child) {

        return ScrollConfiguration(
          behavior: MyBehavior(),
          child: child,
        );
      },

      home: Homes(),

    );
  }
}


class Homes extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Homes> {
  int _currentIndex;
  List<Widget> _children;



  @override
  void initState() {
    _currentIndex = 0;
    _children = [
      MyDealApp(),
      MyRedemptionApp(),
      MyProfileApp()
    ];

    _loadCounter();


    super.initState();
  }

  _loadCounter() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    setState(() {
      myInt = prefs.getInt('id') ?? 0;
      _email = (prefs.getString('email') ?? '');
      _fullname = (prefs.getString('fullname') ?? '');
      currentTabs = prefs.getInt('currentTab') ?? 0;
      debugPrint("currentTabMain:$currentTabMain");
      debugPrint("emailr:$_email");

    });
  }


  @override
  Widget build(BuildContext context) {

    const assetHome = 'assets/home_off.svg';
    const assetRedemptions = 'assets/redeemed_off.svg';
    const assetCommunity = 'assets/community_off.svg';
    const assetProfile = 'assets/profile_off.svg';


    const assetHome1 = 'assets/home_on.svg';
    const assetRedemptions1 = 'assets/redeemed_on.svg';
    const assetCommunity1 = 'assets/community_on.svg';
    const assetProfile1 = 'assets/profile_on.svg';


    return Container(

      height: 30,

        child:CupertinoTabScaffold(

        tabBar: CupertinoTabBar(
          backgroundColor: colorGreen,

          currentIndex: _currentIndex,
          onTap: onTabTapped,
          items: [
            BottomNavigationBarItem(
              icon: _currentIndex == 0 ?SvgPicture.asset(assetHome1,
                  color: Colors.white,
                  width: 20,
                  height: 20,
                  semanticsLabel: 'Home'):SvgPicture.asset(assetHome,
                  color: Colors.white,
                  width: 20,
                  height: 20,
                  semanticsLabel: 'Home'),
            ),
            BottomNavigationBarItem(
              icon:  _currentIndex == 1 ?SvgPicture.asset(assetRedemptions1,
                  color: Colors.white,
                  width: 20,
                  height: 20,
                  semanticsLabel: 'Redemptions'):SvgPicture.asset(assetRedemptions,
                  color: Colors.white,
                  width: 20,
                  height: 20,
                  semanticsLabel: 'Redemptions'),

            ),
            BottomNavigationBarItem( icon:  _currentIndex == 2 ? SvgPicture.asset(assetProfile1,
                color: Colors.white,
                width: 20,
                height: 20,
                semanticsLabel: 'Profile'):SvgPicture.asset(assetProfile,
                color: Colors.white,
                width: 20,
                height: 20,
                semanticsLabel: 'Profile'),

             ),
          ],

        ),
        tabBuilder: (BuildContext context, int index) {
          return CupertinoTabView(
            builder: (BuildContext context) {
              return SafeArea(
                top: false,
                bottom: false,
                child: CupertinoApp(
                  home: CupertinoPageScaffold(
                    resizeToAvoidBottomInset: false,
                    child: _children[_currentIndex],
                  ),
                ),
              );
            },
          );
        }
    ));
  }

  void onTabTapped(int index) {
    setState(() {
      _currentIndex = index;
      debugPrint("tabbottom:$_currentIndex");

    });
  }
}

I used the same for MyRedemptionApp() and MyProfileApp() respectively. The major issue is debugShowCheckedModeBanner: false is not removing the debug banner because the debug banner shows on every page. How to remove the debug banner?

2
  • 2
    I think you have two MaterialApp widget. Please use one MaterialApp. for one app Commented Oct 14, 2020 at 8:10
  • Am using materialapp to stop materialization error which requires materialapp at the root of the application Commented Oct 14, 2020 at 19:08

1 Answer 1

12

This normally happens when you have multiple MaterialApp widgets used. If you don't think you can reduce to one just use debugShowCheckedModeBanner:false whenever you use MaterialApp widgets throughout your application.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.