Flutter-TextField初始化值和選中取值
import 'package:flutter/material.dart';
class PersonalCenterInformationScreen extends StatefulWidget {
@override
_PersonalCenterInformationScreenState createState() => _PersonalCenterInformationScreenState();
}
class _PersonalCenterInformationScreenState extends State<PersonalCenterInformationScreen> {
//初始化賦值
var _username = new TextEditingController();
var age = new TextEditingController();
var _userName;
@override
void initState() {
// TODO: implement initState
super.initState();
this._username.text = '李家長';
this.age.text = '18';
}
@override
Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title:Text('學生個人信息')
),
body: Padding(
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(
'姓名:',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15
),
),
),
Container(
width: width*0.7,
child: TextField(
decoration: InputDecoration(
hintText: '請輸入名字',
),
//利用控制器初始化
controller: this._username,
//發生改變事賦值
onChanged:(val){
this._userName = val;
} ,
),
),
],
),
Row(
children: <Widget>[
Container(
child: Text(
'年齡:',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15
),
),
),
Container(
width: width*0.7,
child: TextField(
decoration: InputDecoration(
hintText: '請輸入年齡',
),
controller: this.age,
),
),
],
),
Row(
children: <Widget>[
Container(
child: Text(
'性別:',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15
),
),
),
],
),
Container(
width: double.infinity,
child: RaisedButton(
child: Text('修改'),
onPressed: (){
//輸出控制台
print(this._userName);
},
),
),
],
),
),
);
}
}
test
Flutter-TextField初始化值和選中取值的更多相关文章
- Mybatis映射文件中#取值时指定参数相关规则
Mybatis映射文件中#取值时指定参数相关规则 在#{}中,除了需要的数值外,还可以规定参数的一些其他规则. 例如:javaType,jdbcType,mode(存储过程),numericScale ...
- 从cookie中取值$.cookie()
从cookie中取值: var userid = $.cookie("remoteuserid");例子: function delUser() { var table = ...
- layui从url中取值 ajax获取当前链接中的变量
在使用layui(javascript)的时候, 需要从当前页面的url地址中取值, 例如: http://localhost:8081/html/fund-purchase.html?fundID ...
- jquery data方法取值与js attr取值的区别
<a data-v="3"></a> jquery data方法的运行机制: 第一次查找dom,使用attributes获取到dom节点值,并将其值存到缓存 ...
- Map 遍历取值及jstl的取值
Map 遍历取值及jstl的取值 学习了:http://blog.csdn.net/yanjiaye520/article/details/17354239 1.Java map的便利取值 Java代 ...
- Python 字符串——巧取值和列表——巧取值 对比
Python 字符串——巧取值和列表——巧取值 对比 1.字符串取值实例: samp_string = "Whatever you are, be a good one." for ...
- set类型没有单独取值功能 通过循环取值
set类型没有单独取值功能 通过循环取值
- struts2 与 OGNL 表达式,jsp中 利用ognl 在valuestack中取值
在Struts2中,一个请求在终于到达Action的方法之前,Action对象本身会被压入ValueStack(实际上就是放到ValueStack的CompoundRoot中),所以Action对象是 ...
- bootstrap timepicker 在angular中取值赋值 并转化为时间戳
上一篇我们讲到angular对于timepicker的一个封装后的插件angular-bootstrap-timepicker,但是由于angular的版本必须是v1.2.30以上的.对于有些涉及到多 ...
随机推荐
- LNMP 搭建 wordpress 站点 安装及配置过程
0x00 环境 阿里云ECS云服务器 CPU:1核 内存:4G 操作系统:Centos 系统盘:100G 0x01 安装及配置 主要使用 nginx . php 和 mysql 注意:如果下面的设置不 ...
- 008-Spring Boot @EnableAutoConfiguration深入分析、内部如何使用EnableAutoConfiguration
一.EnableAutoConfiguration 1.EnableAutoConfiguration原理 springboot程序入口使用注解@SpringBootApplication,Sprin ...
- python接口自动化:对外接口sign签名
签名参数sign生成的方法: 在接口开发过程中,一般通过时间戳+sign作为密匙加密传输 实现代码如下: #python实现sign签名 import hashlib,time class sign: ...
- tips for using shortcuts
tips for using shortcuts for mac: command+ctrl+F:full screen(当前应用全屏之后有一个好处 就是 使用 4 tap 的手势 可以在全屏的界面之 ...
- C#后台获取日期:当天、前七天、后七天
DateTime.Now.ToString(); //当前时间DateTime.Now.AddDays(7).ToString(); //当前时间加上7天DateTime.Now.AddDays(-7 ...
- vue项目 Request Payload改成Form Data
vue项目中提交表单时,请求参数是Request Payload时在main.js中加 axios.defaults.headers.post['Content-Type'] = 'applicati ...
- 关于时间API
如何正确处理时间 现实生活的世界里,时间是不断向前的,如果向前追溯时间的起点,可能是宇宙出生时,又或是宇宙出现之前, 但肯定是我们目前无法找到的,我们不知道现在距离时间原点的精确距离.所以我们要表示时 ...
- Java初始化块及执行顺序
理解 初始化块又称为代码块.属于类中的第四大成员.本质上是一个方法,它也有方法体,但没有方法名,没有参数,没有返回,而且也不是通过对象或类名显式调用,而是通过隐式调用 是构造器的补充 语法 [修饰符] ...
- flume 进阶
一.flume事务 put事务流程: 1.doPut:将批量数据先写入临时缓冲区putList 2.doCommit:检查Channel内存队列是否足够, (1)达到一定时间没有数据写入到putLis ...
- 懵圈了,面试官问一个 TCP 连接可发多少个 HTTP 请求?
作者:松若章 https://zhuanlan.zhihu.com/p/61423830 一道经典的面试题是从 URL 在浏览器被被输入到页面展现的过程中发生了什么,大多数回答都是说请求响应之后 DO ...