24Flutter中常见的表单有TextField单行文本框,TextField多行文本框、CheckBox、Radio、Switch
import 'package:flutter/material.dart'; class TextFieldDemoPage extends StatefulWidget {
TextFieldDemoPage({Key key}) : super(key: key); _TextFieldDemoPageState createState() => _TextFieldDemoPageState();
} class _TextFieldDemoPageState extends State<TextFieldDemoPage> {
var _username=new TextEditingController(); //初始化的时候,给表单赋值:
var _password;
@override
void initState(){
super.initState();
_username.text="初始值";
} @override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('表单演示页面'),
),
body: Padding(
padding: EdgeInsets.all(),
child: Column(
children: <Widget>[
// TextField(),
// SizedBox(height: 20),
// TextField(
// decoration: InputDecoration(
// hintText: "请输入搜索的内容",
// border: OutlineInputBorder()
// ),
// ),
// SizedBox(height: 20),
// TextField( //设置为多行文本框:
// maxLines: 4,
// decoration: InputDecoration(
// hintText: "多行文本框",
// border: OutlineInputBorder()
// ),
// ),
// SizedBox(height: 20),
// TextField(
// obscureText: true, //把文本框修改成密码框:
// decoration: InputDecoration(
// hintText: "密码框",
// border: OutlineInputBorder()
// ),
// ),
// SizedBox(height: 20),
// TextField(
// obscureText: true,
// decoration: InputDecoration(
// hintText: "labelText使用",
// border: OutlineInputBorder(),
// labelText: "用户名"
// ),
// ),
TextDemo(),
TextField(
obscureText: true,
decoration: InputDecoration(
hintText: "labelText使用",
border: OutlineInputBorder(),
labelText: "密码"),
onChanged: (value){
setState(() {
this._password=value;
});
},
),
TextField(
decoration:
InputDecoration(icon: Icon(Icons.search), hintText: "请输入用户名"),
controller: _username,
onChanged: (value){
setState(() {
_username.text=value;
});
},
),
Container(
width: double.infinity,
height: ,
child: RaisedButton(
child: Text("登录"),
onPressed: (){
print(this._username.text);
print(this._password);
},
color: Colors.blue,
textColor: Colors.white,
),
)
],
),
),
);
}
} class TextDemo extends StatelessWidget {
const TextDemo({Key key}) : super(key: key); @override
Widget build(BuildContext context) {
return Container(
child: TextField(
decoration:
InputDecoration(icon: Icon(Icons.people), hintText: "请输入用户名"),
),
);
}
}
CheckBox.dart
import 'package:flutter/material.dart';
class CheckBoxDemoPage extends StatefulWidget {
CheckBoxDemoPage({Key key}) : super(key: key); _CheckBoxDemoPageState createState() => _CheckBoxDemoPageState();
}
// CheckBox
class _CheckBoxDemoPageState extends State<CheckBoxDemoPage> {
var flag=true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppBar(
title: Text('CheckBox'),
),
body:Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
children: <Widget>[
Checkbox(
value: this.flag,
onChanged: (v){
setState(() {
this.flag=v;
});
},
activeColor: Colors.red, )
],
),
Row(
children: <Widget>[
Text(this.flag?'选中':'未选中')
],
),
SizedBox(height: ),
CheckboxListTile(
value: this.flag,
onChanged: (v){
setState(() {
this.flag=v;
});
},
title: Text('标题'),
subtitle: Text('这是一个二级标题'),
secondary: Icon(Icons.help),
)
],
)
);
}
}
24Flutter中常见的表单有TextField单行文本框,TextField多行文本框、CheckBox、Radio、Switch的更多相关文章
- javascript中常见的表单验证项
1.不能超过20个字符 <body> <form name=a onsubmit="return test()"> <textarea name=&q ...
- 在Tomcat中采用基于表单的安全验证
.概述 (1)基于表单的验证 基于From的安全认证可以通过TomcatServer对Form表单中所提供的数据进行验证,基于表单的验证使系统开发者可以自定义用户的登陆页面和报错页面.这种验证方法 ...
- Javascript中的Form表单知识点总结
Javascript中的Form表单知识点总结 在HTML中,表单是由form元素来表示的,但是在javascript中,表单则由HTMLFormElement类型,此元素继承了HTMLElement ...
- php中如何防止表单的重复提交
在php中如何防止表单的重复提交?其实也有几种解决方法. 下面小编就为大家介绍一下吧.需要的朋友可以过来参考下 代码: <?php /* * php中如何防止表单的重复提交 * by www.j ...
- javascript中的常用表单事件用法
下面介绍几种javascript中常用的表单事件: 一,onsubmit:表单中的确认按钮被点击时发生的事件,如下案例. 案例解析:弹出表单中提交的内容 <form name="tes ...
- jquery.form插件中动态修改表单数据
jquery.form jquery.form插件(http://malsup.com/jquery/form/)是大家经常会用到的一个jQuery插件,它可以很方便将表单转换为ajax的方式进行提交 ...
- 如何在.Net Core MVC中为动态表单开启客户端验证
非Core中的请参照: MVC的验证 jquery.validate.unobtrusive mvc验证jquery.unobtrusive-ajax 参照向动态表单增加验证 页面引入相关JS: &l ...
- Vue.js + Nuxt.js 项目中使用 Vee-validate 表单校验
vee-validate 是为 Vue.js 量身打造的表单校验框架,允许您校验输入的内容并显示对应的错误提示信息.它内置了很多常见的校验规则,可以组合使用多种校验规则,大部分场景只需要配置就能实现开 ...
- php中的form表单
表单处理 表单的概念在生活中很常见,就像是问卷调查表一样,别人先把问卷发给你,你照着问卷的要求填写,完事过后再将填完的问卷发给别人,从而达到一个将别人需要的信息传递给别人的一种方式. 传统的网页大多数 ...
随机推荐
- 浅谈Java中的AOP面向切面的变成和控制反转IOC
https://blog.csdn.net/hi_kevin/article/details/7325554 https://www.cnblogs.com/zedosu/p/6632260.html ...
- Codeforces 750 E New Year and Old Subsequence
E. New Year and Old Subsequence 思路:线段树维护矩阵乘法. 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #p ...
- 设计模式之命令模式-JS
理解命令模式 假设有一个快餐店,而我是该餐厅的点餐服务员,那么我一天的工作应该是这样的:当某位客人点餐或者打来订餐电话后,我会把他的需求都写在清单上,然后交给厨房,客人不用关心是哪些厨师帮他炒菜.我们 ...
- Git的撤销操作
https://blog.csdn.net/qq_36431213/article/details/78858848 Git 初接触 (三) Git的撤销操作 git reset HEAD -- gi ...
- 14 webpack中url-loader的使用
默认情况下,webpack无法处理css文件中的url地址,不管是图片还是字体库,只要是URL地址,都处理不了,需要第三方loader 1.安装loader cnpm i url-loader fil ...
- ARP详解
1.学习ARP前要了解的内容 建立TCP连接与ARP的关系 应用接受用户提交的数据,触发TCP建立连接,TCP的第一个SYN报文通过connect函数到达IP层,IP层通过查询路由表: 如果目的IP和 ...
- C++重温历史
这是一篇C#开发重新学习C++的体验文章. 作为一个C#开发为什么要重新学习C++呢?因为在C#在很多业务场景需要调用一些C++编写的COM组件,如果不了解C++,那么,很容易注定是要被C++同事忽悠 ...
- Selenium常用API的使用java语言之18-浏览器cookie操作
有时候我们需要验证浏览器中Cookie是否正确, 因为基于真实Cookie的测试是无法通过白盒测试和集成测试进行的.WebDriver提供了操作Cookie的相关方法可以读取. 添加和删除Cookie ...
- stm32 HardFault_Handler调试及问题查找方法
STM32出现HardFault_Handler故障的原因主要有两个方面: 1.内存溢出或者访问越界.这个需要自己写程序的时候规范代码,遇到了需要慢慢排查. 2.堆栈溢出.增加堆栈的大小. 出现问题时 ...
- BZOJ 3601 一个人的数论 (拉格朗日插值+莫比乌斯反演)
题意 略 题解 orz Freopen的博客 CODE #pragma GCC optimize (3) #include <bits/stdc++.h> using namespace ...