overdeveloping
overdeveloping

Reputation: 790

How to make color part of a text for UI in Flutter?

How can I change the color of part of a text? I'm trying to make it so the text says "Don't have an account? Register now!" but I want to add color to the Register now! part. How can I do this if possible?

image

Upvotes: 11

Views: 8604

Answers (1)

Doc
Doc

Reputation: 11651

Use RichText:

RichText(
        text: TextSpan(
          text: "Don't have an account? ",
          style: TextStyle(color: Colors.black, fontSize: 40),
          children: <TextSpan>[
            TextSpan(text: ' Register now!', style: TextStyle(color: Colors.red)),
          ],
        ),
      );

Result

Upvotes: 30

Related Questions