我应用了 debugshowcheckedmodebanner: false,但仍然在每个屏幕上显示调试标签

Dev*_*er 6 dart flutter flutter-dependencies

我有多个屏幕。所有屏幕都显示调试标签。我正在将debugshowcheckedmodebanner: false, 实现到主文件的材质应用程序中,但调试标签显示在每个屏幕的右上角。我不确定我在哪里犯了错误。

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:async';a
import 'home.dart';

void main() {
  runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    home: splash(),
  ));
}

class splash extends StatefulWidget {
  @override
  _splashState createState() => _splashState();
}

class _splashState extends State<splash> {

  void initState() {
    super.initState();
    Timer(
      Duration(seconds: 3),
          () => Navigator.pushReplacement(
        context,
        MaterialPageRoute(builder: (context) => MyApp(),
      ),
    ));
  }

  @override
  Widget build(BuildContext context) {
    SystemChrome.setEnabledSystemUIOverlays([]);
    Future<bool> _onBackPressed() {
      return showDialog(
          context: context,
          builder: (context) => AlertDialog(
            title: Text("Do you want to exit?"),
            actions: <Widget>[
              FlatButton(
                  onPressed: () {
                    Navigator.pop(context, false);
                  },
                  child: Text("No")),
              FlatButton(
                  onPressed: () {
                    Navigator.pop(context, true);
                  },
                  child: Text("yes"))
            ],
          ));
    }

    Orientatoin();
    return WillPopScope(
      child: Scaffold(
        body: Stack(
          fit: StackFit.expand,
          children: <Widget>[
            Container(
              decoration: BoxDecoration(
                color: Colors.transparent,
              ),
              child: Image.asset('imges/splash.png'),
            ),

          ],
        ),
      ),
      onWillPop: _onBackPressed,
    );
  }
}

void Orientatoin() {
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
}
Run Code Online (Sandbox Code Playgroud)

ali*_*tor 1

确保您没有从开发工具或 android studio/Intellij 屏幕右侧的 flutter 检查器面板中切换横幅。

在您的代码中,它们是a第 3 行中的额外内容。检查您的代码是否可以编译,而不是运行旧版本的代码库。

  • Aligator 我在其他屏幕上有另一个materialApp小部件,所以我删除了那个materialApp(因为整个应用程序应该有一个materialApp小部件),现在一切都很完美。非常感谢您的回复,祝您幸福 (7认同)