颤动中的文本字段

发布于 2025-01-10 17:35:54 字数 182 浏览 2 评论 0原文

如何使文本字段像这样颤动。我想在flutter中开发一个文本字段

flutter 登录图像

how to make text field in flutter like this. I want to develop a text field in flutter

flutter login image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

软甜啾 2025-01-17 17:35:55

希望它对你有用:

 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:

 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,
              ),
            ),
    );
最佳男配角 2025-01-17 17:35:55
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,

                            ),
        
      ]
    )
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,

                            ),
        
      ]
    )
傲娇萝莉攻 2025-01-17 17:35:55

请使用此文本字段代码。在任何地方导入并使用它

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

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
          ),
        ),
      ),
    );
  }
}

This is how you can use this code :

Column(
children : [
    EditText(
          hint: "Enter email",
          isObscure:true,
          keyboardType: TextInputType.number,
          hintFieldColor: Colors.grey,
          marginTop: 20.h,
          maxLength: 1,
          controller: confirmPasswordController,
        ),
]
)
饮惑 2025-01-17 17:35:54

您可以像这样创建 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:

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),
              ),
            ),

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文