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初始化值和選中取值的更多相关文章

  1. Mybatis映射文件中#取值时指定参数相关规则

    Mybatis映射文件中#取值时指定参数相关规则 在#{}中,除了需要的数值外,还可以规定参数的一些其他规则. 例如:javaType,jdbcType,mode(存储过程),numericScale ...

  2. 从cookie中取值$.cookie()

    从cookie中取值: var userid = $.cookie("remoteuserid");例子: function delUser() {     var table = ...

  3. layui从url中取值 ajax获取当前链接中的变量

    在使用layui(javascript)的时候,  需要从当前页面的url地址中取值, 例如: http://localhost:8081/html/fund-purchase.html?fundID ...

  4. jquery data方法取值与js attr取值的区别

    <a data-v="3"></a> jquery data方法的运行机制: 第一次查找dom,使用attributes获取到dom节点值,并将其值存到缓存 ...

  5. Map 遍历取值及jstl的取值

    Map 遍历取值及jstl的取值 学习了:http://blog.csdn.net/yanjiaye520/article/details/17354239 1.Java map的便利取值 Java代 ...

  6. Python 字符串——巧取值和列表——巧取值 对比

    Python 字符串——巧取值和列表——巧取值 对比 1.字符串取值实例: samp_string = "Whatever you are, be a good one." for ...

  7. set类型没有单独取值功能 通过循环取值

    set类型没有单独取值功能 通过循环取值

  8. struts2 与 OGNL 表达式,jsp中 利用ognl 在valuestack中取值

    在Struts2中,一个请求在终于到达Action的方法之前,Action对象本身会被压入ValueStack(实际上就是放到ValueStack的CompoundRoot中),所以Action对象是 ...

  9. bootstrap timepicker 在angular中取值赋值 并转化为时间戳

    上一篇我们讲到angular对于timepicker的一个封装后的插件angular-bootstrap-timepicker,但是由于angular的版本必须是v1.2.30以上的.对于有些涉及到多 ...

随机推荐

  1. 设计模式之动态代理(Java的JDK动态代理实现)

    先来看一下思维导图: 对于JDK的动态代理,孔浩老师说学习的方法是把它记下来. 先写一个主题接口类,表示要完成的一个主题. package com.liwei.dynaproxy; /** * 要代理 ...

  2. ORACLE Physical Standby DG 之fail over

    SQL> select thread#, low_sequence#, high_sequence# from v$archive_gap;确认下是否存在日志间隙,发现gap现象,说明failo ...

  3. an ordered dict within the ordered dict

    w http://stackoverflow.com/questions/20166749/how-to-convert-an-ordereddict-into-a-regular-dict-in-p ...

  4. IPv6 首部格式

    <图解TCP/IP> 4.8 IPv6的首部格式 IPv6为了减轻路由器的负担,省略了首部校验和字段.因此路由器不再需要计算校验和,从而提高了包的转发效率. 此外,分片处理所用的识别码成为 ...

  5. Krypton Suite of .NET WinForms Controls

    The Krypton Suite of .NET WinForms controls are now freely available for use in personal or commeric ...

  6. javascript实现保留两位小数的多种方法

    第一种方法:javascript实现保留两位小数一位自动补零代码实例:第一种方法介绍一下如何实现对数字保留两位小数效果,如果数字的原本小数位数不到两位,那么缺少的就自动补零,这个也是为了统一的效果,先 ...

  7. Nginx https服务器证书安装步骤

    本文档指导您如何在 Nginx 服务器中安装 SSL 证书. 说明: 本文档以证书名称 www.domain.com 为例. Nginx 版本以 nginx/1.16.0 为例. 当前服务器的操作系统 ...

  8. react 样式的写法之一 ---》styled-components的基本使用

    [react]---styled-components的基本使用---[WangQi]   一.官网地址 https://www.styled-components.com/ 二.styled-com ...

  9. .net日志的用法

    public class Logs { private static Logger logger = LogManager.GetCurrentClassLogger(); //初始化日志类 /// ...

  10. 下载JSON数据

    最近学习MongoDB,需要获取大量Json在线数据,例如: http://media.mongodb.org/zips.json 此处使用c#,直接给出代码: HttpWebRequest requ ...