skip to Main Content

I saw people managing to add image in text, like this.

const Text('πŸš€', style: TextStyle(fontSize: 96))

How they do this?

3

Answers


  1. You can use richText.

    RichText(
                text: TextSpan(
                  text: 'This is an ',
                  style: DefaultTextStyle.of(context).style,
                  children: <TextSpan>[
                    TextSpan(
                      text: 'πŸš€', 
                      style: TextStyle(fontSize: 96),
                    ),
                    TextSpan(text: ' icon in text.'),
                  ],
                ),
    
    Login or Signup to reply.
  2. You can add images to text using RichText.

    RichText: (
      text: TextSpan(
        children: [
          Image.asset(β€˜your image’),
          TextSpan: text(β€˜hello’),
        ],
      ),
    ),
    

    You can use not only Image.asset but also Image.network.

    Login or Signup to reply.
  3. You can use below code

    RichText(
      text: TextSpan(
        children: <TextSpan>[
          TextSpan(
            text: 'Hello',  // non-emoji characters
          ),
          TextSpan(
            text: '🧭 🏳️u200d🌈', // emoji characters
          ),
        ],
      ),
    );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search