微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

TextField 后缀动画对齐

如何解决TextField 后缀动画对齐

有人遇到过类似的问题吗? TextField sufixIcon 需要一个像这样的小部件:

TextField(
  decoration: new Inputdecoration(
    suffixIcon: Icon(Icons.ac_unit),),

代码结果

Result of the code

现在我想要同样的东西,但加载动画:

TextField(
  decoration: new Inputdecoration(
    suffixIcon: Container(
    child: SpinKitWave(
      color: Colors.red,size: 20.0,

带动画的代码结果

Result of the code with animation

如果我将 suffixIcon 更改为 sufix,也会发生同样的情况。

问题: 像图标一样右对齐,我尝试使用 Horizo​​ntalAlignment 似乎不起作用。

解决方法

以下是将加载动画对齐到 TextField 右侧的方法:

@override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;
    return SafeArea(
      child: Scaffold(
        body: Center(
          child: Container(
            padding: EdgeInsets.symmetric(horizontal: width * 0.025),child: TextField(
              decoration: InputDecoration(
                border: OutlineInputBorder(
                  borderRadius: const BorderRadius.all(
                    const Radius.circular(60),),filled: true,fillColor: const Color(0xFFE3F8F8),suffixIcon: Container(
                  width: width * 0.2,height: width * 0.1,child: SpinKitWave(
                    color: Colors.red,size: 20.0,prefixIcon: Icon(
                  Icons.search,color: const Color(0x99000000),);
  }

输出:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。