0

I would like to write the company name with the original colors inside the AppBar of the application. For example the word "WhiteRed" with the "White" text in white color and "Red" text in red color. At the moment I am using this method to do it inside the home page but I am not able to reproduce it inside the AppBar.

There is a method for it?

Thanks for your answer

  body: Center(
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Padding(
          padding: const EdgeInsets.only(bottom: 200, top: 200),
          child: Container(
            child: RichText(
              text: const TextSpan(
                children: <TextSpan>[
                  TextSpan(
                      text: 'White',
                      style: TextStyle(color:Colors.white, fontSize: 40, fontWeight: FontWeight.bold)),
                  TextSpan(
                      text: 'Red',
                      style: TextStyle(color: Colors.red, fontSize: 40, fontWeight: FontWeight.bold)),
                ],
              ),
            ),
          ),
        ),
1
  • 1
    Just use the same RichText in the title property of AppBar, it will work. Also consider using Text.rich instead Commented Jan 14, 2024 at 18:07

2 Answers 2

0

You can use Text Widget inside a Row :

  appBar: AppBar(
      title: const Row(children: [
    Text('White', style: TextStyle(color: Colors.white)),
    Text('Red', style: TextStyle(color: Colors.red)),
  ])),
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, easy, it works, as you understand I am a beginner. thanks for the patience
0

You can achieve this by using RichText. Here is the code

Scaffold(
        appBar: AppBar(
          title: RichText(
            text: TextSpan(
              children: [
                TextSpan(
                  text: 'White',
                  style: TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
                ),
                TextSpan(
                  text: 'Red',
                  style: TextStyle(color: Colors.red, fontSize: 24, fontWeight: FontWeight.bold),
                ),
              ],
            ),
          ),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 200, top: 200),
                child: Container(
                  child: RichText(
                    text: const TextSpan(
                      children: [
                        TextSpan(
                          text: 'White',
                          style: TextStyle(color: Colors.white, fontSize: 40, fontWeight: FontWeight.bold),
                        ),
                        TextSpan(
                          text: 'Red',
                          style: TextStyle(color: Colors.red, fontSize: 40, fontWeight: FontWeight.bold),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.