showActionSheet static method
The ActionSheet just like the appearance on the Platform iOS.
Implementation
static Future<int> showActionSheet(BuildContext context, {
required List<String> actions,
}) {
final completer = Completer<int>();
showModalBottomSheet(context: context, builder: (BuildContext context) {
return SafeArea(
child: Container(
color: Colors.white60,
height: Toast.actionSheetItemHeight*(actions.length + 1) +
Toast.actionSheetSeparatorHeight,
child: ListView.builder(
itemCount: actions.length + 1,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int position) {
if (position == actions.length) {
// The Cancel Button.
return InkWell(
child: Container(
margin: const EdgeInsets.fromLTRB(0, 5.0, 0, 0),
color: Colors.white70,///Config.themeColorSeparator,
width: MediaQuery.of(context).size.width,
height: Toast.actionSheetItemHeight,
child: const Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'取消',
style: TextStyle(
color: Colors.redAccent,
fontSize: 16.0,
fontWeight: FontWeight.w500,
),
),
],
),
),
onTap: () {
Navigator.of(context).pop();
completer.complete(Future<int>.value(-1));
},
);
} else {
// The Actions.
return InkWell(
child: Column(
children: <Widget>[
Container(
color: Colors.white,///Config.themeColorSeparator,
width: MediaQuery.of(context).size.width,
height: Toast.actionSheetItemHeight,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
actions[position],
style: const TextStyle(
color: Colors.black,
fontSize: 16.0,
fontWeight: FontWeight.w400,
),
),
],
),
),
const SizedBox(height: 1.0),
],
),
onTap: () {
Navigator.of(context).pop();
completer.complete(Future<int>.value(position));
},
);
}
},
),
),
);
});
return completer.future;
}