一、Flutter常用表单介绍:
CheckboxListTile、RadioListTile、SwitchListTile、Slide。
二、TextField:表单常见属性:
maxLines:设置此参数可以把文本框改为多行文本框
onChanged:文本框改变的时候触发的事件。
decoration:
hintText:类似html中的placeholder
border:配置文本框边框
OutlineInputBorder:配合使用
labelText:lable的名称
labelStyle:配置label的样式
obscureText:把文本框改为密码框
controller:controller结合TextEditingController()可以配置表单默认显示的内容。
三、Checkbox、CheckboxListTile多选框组件:
Checkbox常见属性:
value:true或者false
onChanged改变的时候触发的事件。
activeColor:选中的颜色、背景颜色
checkColor:选中的颜色、Checkbox里面对号的颜色。
CheckboxListTile常见属性:
value:true或者false
onChanged:改变的时候触发的事件。
activeColor:选中的颜色、背景颜色
title:标题
subtitle:二级标题。
secondary:配置图标或者图片。
selected:选中的时候文字颜色是否跟着改变。
TextField.dart
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的更多相关文章

  1. javascript中常见的表单验证项

    1.不能超过20个字符 <body> <form name=a onsubmit="return test()"> <textarea name=&q ...

  2. 在Tomcat中采用基于表单的安全验证

    .概述   (1)基于表单的验证 基于From的安全认证可以通过TomcatServer对Form表单中所提供的数据进行验证,基于表单的验证使系统开发者可以自定义用户的登陆页面和报错页面.这种验证方法 ...

  3. Javascript中的Form表单知识点总结

    Javascript中的Form表单知识点总结 在HTML中,表单是由form元素来表示的,但是在javascript中,表单则由HTMLFormElement类型,此元素继承了HTMLElement ...

  4. php中如何防止表单的重复提交

    在php中如何防止表单的重复提交?其实也有几种解决方法. 下面小编就为大家介绍一下吧.需要的朋友可以过来参考下 代码: <?php /* * php中如何防止表单的重复提交 * by www.j ...

  5. javascript中的常用表单事件用法

    下面介绍几种javascript中常用的表单事件: 一,onsubmit:表单中的确认按钮被点击时发生的事件,如下案例. 案例解析:弹出表单中提交的内容 <form name="tes ...

  6. jquery.form插件中动态修改表单数据

    jquery.form jquery.form插件(http://malsup.com/jquery/form/)是大家经常会用到的一个jQuery插件,它可以很方便将表单转换为ajax的方式进行提交 ...

  7. 如何在.Net Core MVC中为动态表单开启客户端验证

    非Core中的请参照: MVC的验证 jquery.validate.unobtrusive mvc验证jquery.unobtrusive-ajax 参照向动态表单增加验证 页面引入相关JS: &l ...

  8. Vue.js + Nuxt.js 项目中使用 Vee-validate 表单校验

    vee-validate 是为 Vue.js 量身打造的表单校验框架,允许您校验输入的内容并显示对应的错误提示信息.它内置了很多常见的校验规则,可以组合使用多种校验规则,大部分场景只需要配置就能实现开 ...

  9. php中的form表单

    表单处理 表单的概念在生活中很常见,就像是问卷调查表一样,别人先把问卷发给你,你照着问卷的要求填写,完事过后再将填完的问卷发给别人,从而达到一个将别人需要的信息传递给别人的一种方式. 传统的网页大多数 ...

随机推荐

  1. SpringBoot自动配置的魔法是怎么实现的

    SpringBoot 最重要的功能就是自动配置,帮我们省去繁琐重复地配置工作.相信用过SpringBoot的人,都会被它简洁的步骤所惊讶.那么 SpringBoot 是如何实现自动配置的呢? 在这之前 ...

  2. Selenium常用API的使用java语言之12-定位一组元素

    在第(五)节我们已经学习了8种定位方法, 那8种定位方法是针对单个元素定位的, WebDriver还提供了另外8种用于定位一组元素的方法. import org.openqa.selenium.By; ...

  3. [CSS] The :empty Pseudo Selector Gotchas

    The :empty pseudo selector selects empty elements. We can use this to display useful messages instea ...

  4. 使用quickstart方式快速搭建maven工程

    通常idea 创建maven工程,初始化会比较慢,针对这种现象.我们可以使用一些巧妙的方式来帮助快速搭建 废话不多说直接上图! 图1 使用 archetype-quickstart  选择 图二 点击 ...

  5. iwap问题

    1. 2. . . ========================================================================================== ...

  6. 「CF319E」Ping-Pong「线段树」「并查集」

    题意 规定区间\((a,b)\)到区间\((c,d)\)有边当且仅当\(c<a<d\)或\(c<b<d\). 起初区间集合为空.有\(n\)(\(n\leq 10^5\))次操 ...

  7. opencv 学习一安装环境vs2015+opencv3

    参考博客 http://www.cnblogs.com/skyfsm/p/6840202.html 针对 模块计算机类型“X64”与目标计算机类型“X86”这个问题,我使用cmake 对环境的工程进行 ...

  8. Proxmox VE 的安装和简单使用

    Proxmox VE Proxmox ve 安装 如果proxmox源太慢了.可以使用国内源 download.proxmox.wiki 直接替换就可以了. ISO U盘方式安装 下载地址:https ...

  9. [信息收集]11种绕过CDN查找真实IP方法【转载】

    今天在看一些有关CDN的文章的时候,发现一篇写的蛮好的文章,故转载过来. 原文链接:https://www.cnblogs.com/qiudabai/p/9763739.html 0x01 验证是否存 ...

  10. Multiple commands produce "*.framework"

    参考链接记录个问题,这是xcode10后新build系统导致的,新系统帮我们检查了很多东西,最优化我们的构建, 两种方案 1.用旧的系统(不推荐)   2.这个是build setting->b ...