Reputation: 149
I have finished the rest of the dialog, but the top side has a round overflow avatar. I don’t know how to do it now. As shown in this picture
Upvotes: 1
Views: 515
Reputation: 911
You need to create a Home Screen Widget to call a function showDialog in any button, when Pressed or Tap, passing the arguments that you need, like QRCode Image and Avatar.
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: FlatButton(
color: Colors.blue,
child: Text("My Dialog"),
onPressed: () => {
showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) => MyDialog(),
),
},
),
),
);
}
}
Finally create its Dialog Class and use Stack and Positioned to put Avatar on top of Dialog Content.
class MyDialog extends StatelessWidget {
MyDialog({
Key key,
// Something you need like a QRCode and Avatar Image
}) : super(key: key);
@override
Widget build(BuildContext context) {
double radius = 50;
double padding = 10;
double hSize = 400;
double wSize = 400;
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
elevation: 0.0,
backgroundColor: Colors.transparent,
child: Container(
width: 400,
child: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.all(padding),
margin: EdgeInsets.only(top: radius),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(padding),
),
height: hSize,
width: wSize,
),
Positioned(
left: padding,
right: padding,
child: CircleAvatar(
backgroundColor: Colors.indigo,
radius: radius,
),
),
],
),
),
);
}
}
This is Result:
Upvotes: 4
Reputation: 3383
Can be solved with the Badges plugin. Wrap the QRCode with Badge and modify the position parameter which is a BadgePosition to the exact top and left values.
Badge(
position: BadgePosition.topLeft(top: 0,left: 0),//change this to get the right location
badgeContent: YourAvatar(),
child: YourQRImage(),
)
Upvotes: 0