Home > Software engineering >  How Flutter adds a top-level view (similar to iOS adding to a window)
How Flutter adds a top-level view (similar to iOS adding to a window)

Time:05-17

enter image description here The widget is always displayed on the screen, just like in iOS, adding controls to the window. How to achieve it, thank you! Grateful!

CodePudding user response:

Add this to your MaterialApp to remove it

MaterialApp(
  debugShowCheckedModeBanner: false,
)

CodePudding user response:

You can use Banner widget that actually displays debug banner.

docs link : https://api.flutter.dev/flutter/widgets/Banner-class.html

 Banner(
          location: BannerLocation.topEnd,
          message: "",
          child: Icon(Icons.help), //you can pass anything here as widget
          color: Colors.transparent,
        ),    

CodePudding user response:

Have a look at this. Flutter provides a default Banner widget.It is somewhat similar to the debug banner what we are used to of seeing on the top-right corner on a flutter app in debug mode.

https://api.flutter.dev/flutter/widgets/Banner-class.html

CodePudding user response:

You can use Stack Widget to overlay Widgets over one another. For example:

Stack(
  children: <Widget>[
    Container(
      width: 100,
      height: 100,
      color: Colors.red,
    ),
    Container(
      width: 90,
      height: 90,
      color: Colors.green,
    ),
    Container(
      width: 80,
      height: 80,
      color: Colors.blue,
    ),
  ],
)

The Banner widget realises this by creating a CustomPainter, take a look at the Implementation. But I think a Stack would be the better choice here if you are using Widgets.

  • Related