直播app原始碼,Flutter 彈窗元件

zhibo系統開發發表於2021-11-23

直播app原始碼,Flutter 彈窗元件實現的各種形式

彈窗系列元件

AlertDialog
showDialog(
    context: context,
    builder: (BuildContext context) {
        return AlertDialog(
            title: Text("提示"),
            content: Text("確定刪除嗎?"),
            actions: [
                FlatButton(onPressed: () {}, child: Text("取消")),
                FlatButton(onPressed: () {}, child: Text("確定")),
            ],
        );
    },
);

AlertDialog 自定義樣式

showDialog(
    context: context,
    builder: (BuildContext context) {
        return AlertDialog(
            title: Center(child: Text("提示")),
            titleTextStyle: TextStyle(
                fontWeight: FontWeight.bold,
                color: Colors.black,
                fontSize: 30,
            ),
            content: Center(heightFactor: 1, child: Text("確定刪除嗎?")),
            backgroundColor: Colors.yellowAccent,
            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
            actionsAlignment: MainAxisAlignment.center,
            actions: [
                FlatButton(
                    onPressed: () {
                        Navigator.of(context).pop("no");
                    },
                    child: Text("取消"),
                ),
                FlatButton(
                    onPressed: () {
                        Navigator.of(context).pop("yes");
                    },
                    child: Text("確定"),
                ),
            ],
        );
    },
);

 CupertinoAlertDialog IOS風格

 showCupertinoDialog(
    //點選空白處取消
    barrierDismissible: true,
    context: context,
    builder: (context) {
        return CupertinoAlertDialog(
            title: Text("提示"),
            content: Text("確認刪除嗎?"),
            actions: [
                CupertinoDialogAction(
                    child: Text("取消"),
                    onPressed: () {
                        Navigator.of(context).pop();
                    },
                ),
                CupertinoDialogAction(
                    child: Text("確定"),
                    onPressed: () {},
                ),
            ],
        );
    },
);

以上就是直播app原始碼,Flutter 彈窗元件實現的各種形式, 更多內容歡迎關注之後的文章 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2843689/,如需轉載,請註明出處,否則將追究法律責任。

相關文章