Flutter 写一个dialog
时间: 2024-05-06 10:20:58 浏览: 170
好的,可以为您提供一个基础的 Flutter Dialog 示例代码:
```dart
import 'package:flutter/material.dart';
class MyDialog extends StatefulWidget {
@override
_MyDialogState createState() => _MyDialogState();
}
class _MyDialogState extends State<MyDialog> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text("Dialog Title"),
content: Text("This is the dialog content."),
actions: <Widget>[
FlatButton(
child: Text("Cancel"),
onPressed: () {
Navigator.of(context).pop();
},
),
FlatButton(
child: Text("Confirm"),
onPressed: () {
// do something after confirm
Navigator.of(context).pop();
},
),
],
);
}
}
```
您可以根据自己的需要进行修改和定制。
阅读全文