Flutter完全开发手册

    Flutter中GetX Dialog中间弹框

    Dialog底层其实是对AlertDialog进行了封装,一般用于二次确认的弹出框,比如当点击某个按钮提交资料时,需要用户二次确认,以防止误操作。

    Flutter Get.defaultDialog

    
    Get.defaultDialog(
      title: "提示",
      middleText: "您确定要清空历史记录吗",
      middleTextStyle:
    	  TextStyle(fontSize: ScreenUtils.fontSize(50)),
      radius: 10.0,
      confirm: ElevatedButton(
    	  style: ButtonStyle(
    		backgroundColor:
    			MaterialStateProperty.all(Colors.red),
    		foregroundColor:
    			MaterialStateProperty.all(Colors.white),
    		shape: MaterialStateProperty.all(
    			RoundedRectangleBorder(
    				borderRadius:
    					BorderRadius.circular(20))),
    	  ),
    	  onPressed: () {
    		controller.clearHistoryData();
    		Get.back();
    	  },
    	  child: const Text("确定")),
      cancel: ElevatedButton(
    	style: ButtonStyle(
    	  backgroundColor:
    		  MaterialStateProperty.all(Colors.yellow),
    	  foregroundColor:
    		  MaterialStateProperty.all(Colors.black54),
    	  shape: MaterialStateProperty.all(
    		  RoundedRectangleBorder(
    			  borderRadius: BorderRadius.circular(20))),
    	),
    	onPressed: () {
    	  print("取消");
    	  Get.back();
    	},
    	child: const Text("取消"),
      ),
    );
    
    上一篇:Flutter Timer实现短信验证码60s倒计时下一篇:没有了