1

Is there an analog of modeless dialog in Flutter? If not, it's possible build widget with properties of modeless dialog?

I will try to explain in more detail. My source question was edited. By clicking the canvas, I've must call _handleTapDown function:

void _handleTapDown (TapDownDetails details)
{
      _showModeless (context);
}

In this function, need to visualize your Modeless widget:

void _showModeless (BuildContext context)
{
// How do I show Modeless Widget?
}
Michael Kanzieper
  • 709
  • 1
  • 10
  • 20
  • Please add few more details as to help others better understand your problem, and if possible code sample, or images of what you want or trying to achieve. – Ganapat Jun 18 '18 at 18:51
  • You can create modeless dialogue. check showDialogue method, and create your own custimized – Tree Jun 18 '18 at 19:21
  • @Tree that creates a modal dialog in that it blocks the rest of the screen, which I think is what the OP is trying to avoid. Although some clarification of that is needed. – rmtmckenzie Jun 18 '18 at 19:25
  • Modeless is just the opposite of modal. `showDialog` only show modals. `Overlay` is for modaless – Rémi Rousselet Jun 18 '18 at 19:37
  • I was try to explain in more detail: my source question has been updated. – Michael Kanzieper Jun 20 '18 at 14:53

2 Answers2

2

You can use Overlay to add widget above everything else ; and use them however you like.

enter image description here

class ModeLess extends StatefulWidget {
  final Widget child;

  ModeLess({this.child});

  @override
  _ModeLessState createState() => new _ModeLessState();
}

class _ModeLessState extends State<ModeLess> {
  OverlayEntry modeless;

  @override
  void initState() {
    super.initState();
    modeless = new OverlayEntry(
        opaque: false,
        builder: (context) {
          return new Positioned(
            top: 50.0,
            left: 50.0,
            child: new SizedBox(
              height: 50.0,
              child: new Card(
                child: new Text("I'm a modeless")
              ),
            ),
          );
        });

    Future.microtask(() {
      Overlay.of(context).insert(modeless);
    });
  }

  @override
  void dispose() {
    modeless.remove();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return widget.child;
  }
}
Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
0

Rémi Rousselet, thank you very much. Your advice has helped. Below is the prototype of function that I need:

  OverlayEntry
    _modeless = null;

  void _showModeless(BuildContext context)
  {
     _modeless = new OverlayEntry(
        opaque: false,
        builder: (context) {
          return new Positioned(
            top: 100.0,
            left: 100.0,
            child:
            new Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                new Icon(Icons.content_paste, color: Colors.blueGrey),
                  new Padding(
                    padding: const EdgeInsets.only(left: 16.0),
                    child: new Text('Modeless', overflow: TextOverflow.ellipsis,
                      style: new TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold, color: Colors.lightBlue, decoration: TextDecoration.none
                      ),
                    ),
                  ),
              ],
            ),
          );
        });
    Overlay.of(context).insert(_modeless);
     _startWaiting();
  }

 static const TIMEOUT = const Duration(seconds: 8);
 static Timer _timer = null;

  void _startWaiting()
  {
    _timer = new Timer(TIMEOUT, _handleTimeout);
  }

  void _handleTimeout()
  {
    if (_modeless != null)
      _modeless.remove();
  }

PS. I added only another function that allows to remove the modeless after 8 sec. Once again many thanks.

Michael Kanzieper
  • 709
  • 1
  • 10
  • 20