Hello I'm working on an language application and when user clicks on a word, i want to show a custom dialog like this: enter image description here
How can i implement a custom dialog?
2.2k Views Asked by Jderbilos At
3
There are 3 best solutions below
1
On
better use Dialog widget than AlertDialog
showDialog(
context: context,
builder: (BuildContext context) =>
Dialog(
child: Container(Text("hello")));
2
On
Try below code hope it helpful to you.use flutter_custom_clippers package for your design add this package in your pubspec.yaml file, import below package in your code file
import 'package:flutter_custom_clippers/flutter_custom_clippers.dart';
your alert function:
customAlert() {
showDialog(
context: context,
builder: (BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ClipPath(
clipper: MessageClipper(),
child: Container(
margin: EdgeInsets.all(10),
height: 150,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(16.0),
),
color: Colors.blue,
),
child: Center(
child: Text("Add Your Text Here",
style: TextStyle(
color: Colors.white,
)),
),
),
),
],
);
},
);
}
Your Widget:
TextButton(
child: Text('Alert'),
onPressed: () =>
customAlert(),
),

When you call
showDialog, inside the builder you usually return an instance ofAlertDialog. The content ofAlertDialogcan be any widget. Use your custom widget insideAlertDialogand you are set.