Search code examples
flutterdartwidgetflutter-layoutflutter-dependencies

How can I put a widget above another widget in Flutter?


I would like to overlay a Round view on top of a background View just like in this screenshot below.

Getting like this


Solution

  • @override
    Widget build(BuildContext context) {
    // TODO: implement build
    return new Container(
      width: 150.0,
      height: 150.0,
      child: new Stack(children: <Widget>[
        new Container(
          alignment: Alignment.center,
          color: Colors.redAccent,
          child: Text('Hello'),
        ),
        new Align(alignment: Alignment.bottomRight,
          child: FloatingActionButton(
            child: new Icon(Icons.add),
              onPressed: (){}),
        )
      ],
      ),
    );
    }
    

    above UI will look like this