Papouche Guinslyzinho
Papouche Guinslyzinho

Reputation: 5448

How to see the text when using the RichText widget

I am reading the Text Widget documentation for Flutter. I was wondering why I don't see the text on the screen using the RichText widget. When I use the Text and Text.Rich widget I am able to see the text right away but I can't see the text for RichText.

return MaterialApp(
  title: 'Text Widget Documentation',
  home: Scaffold(
  body: Center(
    child: Container(
      child: RichText(
          text: TextSpan(
              text: 'Tutorial',
              style: TextStyle(
                  fontSize: 30, 
                  fontFamily: 'Roboto')
                  ),
          textScaleFactor: 2,
        ),
      ),
    ),
  ),
);

Upvotes: 0

Views: 318

Answers (1)

GirlWhoCode
GirlWhoCode

Reputation: 628

Your text must be inside children of TextSpan , so you can make more then one text thats why its called RichText, so you can make a long Text with different color or style.
this the link of flutter.dev : https://api.flutter.dev/flutter/widgets/RichText-class.html

RichText(
                  text: TextSpan(
                      style: TextStyle(
                          fontSize: 30, 
                          fontFamily: 'Roboto')
                          ),
                      textScaleFactor: 2,
                      children: <TextSpan>[
                       new TextSpan(
                                text: 'Your text here',
                                    style: new TextStyle(
                                    fontWeight: widget.fontWeight,
                                    )), 
                        TextSpan(// othen then)

               ]))

Upvotes: 2

Related Questions