如何使文本字段像这样颤动。我想在flutter中开发一个文本字段
how to make text field in flutter like this. I want to develop a text field in flutter
希望它对你有用:
TextField( decoration: InputDecoration( filled: true, fillColor: Colors.white.withOpacity(0.6), hintText: "Email address", hintStyle: TextStyle( color: Colors.grey[400], fontWeight: FontWeight.bold ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(20), borderSide: BorderSide.none, ), ), );
Hope it works for you:
Column( children:[ const TextField( decoration: InputDecoration( fillColor: Colors.white, filled: true, isDense: true, contentPadding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), // counter: Container(), counterText: '', hintStyle: TextStyle( color: Colors.grey, fontWeight: FontWeight.w700, fontSize: 18), hintText: 'Email Address', focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.all( Radius.circular(12.0), ), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.all( Radius.circular(12.0), ), ), ), keyboardType: TextInputType.emailAddress, textInputAction: TextInputAction.next, ), SizedBox(height: 20), const TextField( decoration: InputDecoration( fillColor: Colors.white, filled: true, isDense: true, contentPadding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), // counter: Container(), counterText: '', hintStyle: TextStyle( color: Colors.grey, fontWeight: FontWeight.w700, fontSize: 18), hintText: 'Password', focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.all( Radius.circular(8.0), ), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.all( Radius.circular(8.0), ), ), ), keyboardType: TextInputType.visiblePassword, obscureText: true, textInputAction: TextInputAction.done, ), ] )
请使用此文本字段代码。在任何地方导入并使用它
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:personal_diary/app/data/SelectedTheme.dart'; import 'package:personal_diary/app/data/ThemeData.dart'; class EditText extends StatelessWidget { // final Color textColor; final String hint; final int maxLine; final int? maxLength; final bool isObscure; final Color? textFieldColor, hintFieldColor; final TextInputType? keyboardType; final ThemeDetails themeDetails = SelectedTheme.instance.getTheme(); final double marginTop, marginBottom, marginLeft, marginRight; final TextEditingController? controller; final bool isReadOnly; final double? fontSize; final double? height; final String? Function(String? val)? validator; EditText( {required this.hint, this.maxLine = 1, this.maxLength, this.fontSize, this.isReadOnly = false, this.isObscure = false, this.keyboardType, this.marginTop = 0.0, this.marginBottom = 0.0, this.height, this.marginLeft = 0.0, this.textFieldColor, this.hintFieldColor, this.validator, this.marginRight = 0.0, this.controller}); @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white.withOpacity(0.85), borderRadius: BorderRadius.all(Radius.circular(12.sp))), padding: EdgeInsets.only(left: 10.w), margin: EdgeInsets.only( top: marginTop, bottom: marginBottom, right: marginRight, left: marginLeft), child: TextFormField( style: TextStyle( color: Colors.black, fontSize: fontSize ?? 14.sp, height: height, ), controller: controller, maxLines: maxLine, readOnly: isReadOnly, maxLength: maxLength, validator: validator, keyboardType: keyboardType, obscureText: isObscure, decoration: InputDecoration( hintText: hint, border: InputBorder.none, counterText: '', hintStyle: TextStyle( color: Colors.grey, fontSize: 14.sp ), ), ), ); } }
这是使用此代码的方式:
Column( children : [ EditText( hint: "Enter email", isObscure:true, keyboardType: TextInputType.number, hintFieldColor: Colors.grey, marginTop: 20.h, maxLength: 1, controller: confirmPasswordController, ), ] )
Please use this text field code. Import and use it everywhere
This is how you can use this code :
您可以像这样创建 TextField:
TextField
TextField( decoration: InputDecoration( filled: true, fillColor: Colors.white, focusColor: Colors.white, focusedBorder: OutlineInputBorder( borderSide: const BorderSide(color: Colors.white, width: 2.0), borderRadius: BorderRadius.circular(30), ), border: OutlineInputBorder( borderSide: const BorderSide(color: Colors.white, width: 2.0), borderRadius: BorderRadius.circular(30), ), enabledBorder: OutlineInputBorder( borderSide: const BorderSide(color: Colors.white, width: 2.0), borderRadius: BorderRadius.circular(30), ), hintText: 'Email address', hintStyle: const TextStyle(color: Colors.grey), ), ),
You can make this TextField like this:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(4)
希望它对你有用:
Hope it works for you:
请使用此文本字段代码。在任何地方导入并使用它
这是使用此代码的方式:
Please use this text field code. Import and use it everywhere
This is how you can use this code :
您可以像这样创建
TextField
:You can make this
TextField
like this: