

Flutter 禁用按钮/禁止按钮点击
source link: https://www.bugcatt.com/archives/2071
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

需具备的条件
若要顺利阅读本篇文章, 需要你具备如下条件:
本篇文章的环境:
环境版本Windows10Android Studio3.5Flutter1.19.0-2.0.pre
创建一个空项目.
删除./test
目录.
替换./lib/main.dart
为:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Disable Button',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Disable Button'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
// 是否开启按钮
bool isEnabled = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 开关控件
CupertinoSwitch(
value: this.isEnabled,
onChanged: (bool value) {
setState(() {
this.isEnabled = value;
});
},
),
RaisedButton(child: Text("目标按钮", style: TextStyle(fontSize: 25,color: Colors.white)), color: Colors.blue,onPressed: (){}),
],
),
),
);
}
}
Recommend
-
188
-
8
js如何判断哪个按钮被点击了?发布于 2015-09-16 页面上有两个按钮,点击后都调用同样的js函数,只是传入的参数不同,请问如何在这个函数中判断是点...
-
7
1. 多按钮被点击
-
6
如何改变所有按钮的点击行为? 欧雷 发表于 1 天之前 0 条评论 被人问了这样一个问题—— 现在有这样...
-
8
在 Web 中,大部分按钮可能都是平平无奇的,有时候为了强调品牌特殊或者满足特殊功能,可能需要给按钮添加一点点击动效。比如,用过
-
10
限时限次数点击按钮更新日期: 2022-03-25阅读量: 26标签: 定时器分享扫一...
-
6
js复制文本到剪切板有很多方法,很多朋友会用开源库,其实纯js的方式实现也很简单。关于复制和剪切板,之前也写过很多文章,例如。 javascript execCommand,复文本框神器
-
5
还在用 JS 做节流吗?CSS 也可以防止按钮重复点击 作者:XboxYan 2022-11-14 18:43:03 CSS 实现“节流”其实就是控制一个动画的精准控制,假设有一个动画控制按钮从禁用->可点击的变化,每次点击时让这个动画重新...
-
8
CSS实现防止按钮重复点击,双击进入两次单机的情况 2022年11月17日 23次浏览 之前有文章写过如何避免双击进入两次单机的情况,当然...
-
3
在...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK