开发者社区> 问答> 正文

如何创建字符串输入字段颤动?

我的模拟器看起来像

Android模拟器

如何创建字符串输入字段颤动?

将键盘类型更改为文本,将输入值更改为文本字段名称的字符串。

展开
收起
Puppet 2020-01-06 22:31:46 465 0
1 条回答
写回答
取消 提交回答
  • 更改

     keyboardType: TextInputType.text
    检查我的main.dart文件
    
    import 'package:flutter/material.dart';void main() => runApp(new MyApp());
    class MyApp extends StatelessWidget{
      @override
      Widget build(BuildContext context){
        Color hexToColor(String code) {
          return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000);
        }return MaterialApp(
            debugShowCheckedModeBanner: false,
            title: "End User Page",
            home: new Material(
                child: new Container (
                    padding: const EdgeInsets.all(30.0),
                    color: Colors.white,
                    child: new Container(
                      child: new Center(
                          child: new Column(
                              children : [
                                new Padding(padding: EdgeInsets.only(top: 140.0)),
                                new Text('Name:',
                                  style: new TextStyle(color: hexToColor("#F2A03D"), fontSize: 25.0),),
                                new Padding(padding: EdgeInsets.only(top: 50.0)),
                                new TextFormField(
                                  decoration: new InputDecoration(
                                    labelText: "Enter Name",
                                    fillColor: Colors.white,
                                    border: new OutlineInputBorder(
                                      borderRadius: new BorderRadius.circular(25.0),
                                      borderSide: new BorderSide(
                                      ),
                                    ),
                                    //fillColor: Colors.green
                                  ),
                                  validator: (val) {
                                    if(val.length==0) {
                                      return "Name cannot be empty";
                                    }else{
                                      return null;
                                    }
                                  },
                                  keyboardType: TextInputType.text,
                                  style: new TextStyle(
                                    fontFamily: "Poppins",
                                  ),
                                ),
                              ]
                          )
                      ),)
    
    
                )
            )
        );}
    }
    

    输出:

    仿真器

    干杯!

    2020-01-06 22:32:05
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载