I would like to overlay a Round view on top of a background View just like in this screenshot below.
Asked
Active
Viewed 4.9k times
33
-
1https://docs.flutter.io/flutter/widgets/Stack-class.html – Günter Zöchbauer Aug 24 '18 at 06:40
4 Answers
64
@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: (){}),
)
],
),
);
}

Sher Ali
- 5,513
- 2
- 27
- 29
18
You can use the Stack widget.
Stack(
children: [
/*your_widget_1*/,
/*your_widget_2*/,
],
);

Binozo
- 145
- 2
- 10

tudorprodan
- 950
- 8
- 18
-
1The correct Stack class URL: https://api.flutter.dev/flutter/widgets/Stack-class.html – Tinh Huynh Dec 26 '21 at 06:49
3
Stack(
alignment: Alignment.topRight,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
child: Image.network(
image,
height: 150,
width: 100,
fit: BoxFit.fitHeight,
),
borderRadius: new BorderRadius.circular(8.0),
),
),
new Align(alignment: Alignment.topRight,
child:ClipRRect(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(30),
bottomLeft: Radius.circular(30),
topRight: Radius.circular(30)),
child: RaisedButton(
elevation: 1,
color: Color(0xFF69C86C),
child: Text(
"Name",
style: TextStyle(color: Colors.white),
),
onPressed: () {},
),
),
)
],
),

Dharman
- 30,962
- 25
- 85
- 135

Muhammad Ashraf
- 3,323
- 2
- 12
- 19
1
You can also use IndexedStack
if you wish to show only one of the children based on the index.
IndexedStack(
index: 0,
children: [
FooWidget(), // Visible if index = 0
BarWidget(), // Visible if index = 1
],
)

CopsOnRoad
- 237,138
- 77
- 654
- 440