import 'package:flutter/material.dart';
typedef IndexCallback = void Function(int index);
// ignore: avoid_types_as_parameter_names
Widget showAlertView(String title, String content, BuildContext context,
{Key key, IndexCallback callBack}) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext showContext) {
return AlertDialog(
title: Container(
alignment: Alignment.center,
child: Text(title),
),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Container(
alignment: Alignment.center,
child: Text(content),
),
],
),
),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: <Widget>[
FlatButton(
child: Text('取消'),
onPressed: () {
Navigator.of(showContext).pop();
callBack(0);
},
),
FlatButton(
child: Text('确定'),
onPressed: () {
callBack(1);
Navigator.of(showContext).pop();
},
),
],
);
}).then((value) => print(value));
}
|