How to show Icon in Text widget in flutter?

前端 未结 7 600
悲&欢浪女
悲&欢浪女 2020-12-28 13:24

I want to show an icon in text widget. How do I do this ?

The following code only shows the IconData

Text(\"Click ${Icons.add} to add\"         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 14:18

    An alternative might be to use emoji.

    In Dart, strings supports escape sequences for special characters. For unicode emoji, you can use \u and curly braces with emoji hex code inside. Like this:

    Text('Click \u{2795} to add')
    

    The result is:

    You can find a complete unicode emoji list here: http://unicode.org/Public/emoji/1.0/emoji-data.txt

提交回复
热议问题