這是我的輸出,

單擊麥克風按鈕時,我嘗試撰寫一個彈出對話框。但是當我點擊它時,它不起作用。并且對話框代碼在另一個 dart 檔案中。我希望這不是問題。
麥克風影像代碼
Center(
child: Padding(
padding: const EdgeInsets.only(top: 1),
child: IconButton(
iconSize: 45,
icon: Ink.image(
image: const AssetImage('assets/mic.png'),
),
onPressed: () {
// do something when the button is pressed
Recorder12(context);
},
),
),
),
它在另一個頁面中的對話框代碼
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:material_dialogs/material_dialogs.dart';
import 'package:material_dialogs/widgets/buttons/icon_button.dart';
import 'package:material_dialogs/widgets/buttons/icon_outline_button.dart';
Widget Recorder12(BuildContext context) {
return MaterialButton(
color: Colors.grey[300],
minWidth: 300,
onPressed: () => Dialogs.materialDialog(
msg: 'Are you sure ? you can\'t undo this',
title: "Delete",
color: Colors.white,
context: context,
dialogWidth: kIsWeb ? 0.3 : null,
onClose: (value) => print("returned value is '$value'"),
actions: [
IconsOutlineButton(
onPressed: () {
Navigator.of(context).pop(['Test', 'List']);
},
text: 'Cancel',
iconData: Icons.cancel_outlined,
textStyle: TextStyle(color: Colors.grey),
iconColor: Colors.grey,
),
IconsButton(
onPressed: () {},
text: "Delete",
iconData: Icons.delete,
color: Colors.red,
textStyle: TextStyle(color: Colors.white),
iconColor: Colors.white,
),
]),
child: Text("Show Material Dialog"),
);
}
依賴 材料_對話框:^1.1.3
uj5u.com熱心網友回復:
在您的Recorder12班級 remove 中MaterialButton,您將 button 放入 button 并將 Recorder12 更改為 return void:
Void Recorder12(BuildContext context) {
Dialogs.materialDialog(
msg: 'Are you sure ? you can\'t undo this',
title: "Delete",
color: Colors.white,
context: context,
dialogWidth: kIsWeb ? 0.3 : null,
onClose: (value) => print("returned value is '$value'"),
actions: [
IconsOutlineButton(
onPressed: () {
Navigator.of(context).pop(['Test', 'List']);
},
text: 'Cancel',
iconData: Icons.cancel_outlined,
textStyle: TextStyle(color: Colors.grey),
iconColor: Colors.grey,
),
IconsButton(
onPressed: () {},
text: "Delete",
iconData: Icons.delete,
color: Colors.red,
textStyle: TextStyle(color: Colors.white),
iconColor: Colors.white,
),
]);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/517377.html
標籤:扑
