简体   繁体   English

如何将 Flutter 中的按钮图标更改为动画文本?

[英]How to Change Button Icon to Animated Text in Flutter?

I am Facing Some Issues on this Topic.我在这个主题上面临一些问题。 I have a Material Button.我有一个材质按钮。 as you can see in the Code below there is an "Emoticon" icon is Set for it.正如您在下面的代码中看到的那样,为它设置了一个“表情”图标。

            MaterialButton(
                    onPressed: () {},
                    // color: Colors.transparent,
                    child: Icon(
                      Icons.emoji_emotions_outlined,
                      color: Colors.black54,
                      size: 35,
                    ),
                    shape: CircleBorder(),
                    padding: EdgeInsets.all(16),
                  ),
                ],
              ),

I also Have a Text Field which Looks like, this, (below),我也有一个看起来像这样的文本字段(如下),

                TextFormField(
                  // autofocus: true,
                  decoration: InputDecoration(
                    labelText: 'Write Task',
                    // border: OutlineInputBorder(),
                    prefixIcon: Icon(Icons.add),
                  ),
                ),

After the user is done writing I need to Show up this List of emojis [,,,,,,] One by one in the Delay of One Second.用户写完后,我需要在一秒的延迟中一个一个地显示这个表情符号List [,,,,,,] inside the Material Button, Place Above, in the place of Icon.在 Material Button 里面,Place Above,在 Icon 的地方。

  1. I have a Material Button我有一个材质按钮
  2. I have an Icon Inside it.我里面有一个图标。
  3. I also Have a Text Field我也有一个文本字段
  4. After TextField is Done Writing, I need to Show List of emojis [,,,,,,] TextField 完成编写后,我需要显示表情符号List [,,,,,,]
  5. I want to replace the Icon in the Material Button.我想替换材质按钮中的图标。
  6. And I want to Show a Slide Show of These Emojis Except the Button's Icon我想显示这些表情符号的幻灯片放映,除了按钮的图标
  7. Also If user Clicks on Emoji the Emoji Gets Locked, or Store in Some kind of Variable此外,如果用户单击 Emoji,则 Emoji 会被锁定,或存储在某种变量中

I really want to Seek Help at this.我真的很想在这方面寻求帮助。

Two things here,这里有两件事,

  • Initially one icon is shown in material button.最初,材料按钮中显示一个图标。 As per the user's interaction the icon will be changed.根据用户的交互,图标将被更改。
    To achieve this, create instance of IconData (as Icon accepts IconData ) and initially set the default icon.为此,创建IconData的实例(因为Icon接受IconData )并最初设置默认图标。 You can set the selected IconData to the variable whenever user selects another icon.每当用户选择另一个图标时,您都可以将选定的IconData设置为变量。

  • I don't know whether this traditional icons are there in Material Icons library or not.我不知道这个传统图标是否在 Material Icons 库中。 Check font_awesome_flutter otherwise.否则检查font_awesome_flutter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM