Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Google font color is ignored

I have an OutlineButton where I try to use a google font for the text using the google-fonts dependency. The code looks like that:

OutlinedButton(
  child: const Text('Next'),
  style: ButtonStyle(
    backgroundColor: MaterialStateProperty.resolveWith((states) {
      return colorPrimaryButton;
    }),
    textStyle: MaterialStateProperty.resolveWith((states) {
      return GoogleFonts.inter(textStyle: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white));
    })
  ),
  onPressed: () {
    // do something
  }),

Although I assigned white as the text color, the text appears blue-ish.

What am I missing here? Why wouldn’t the "Next" text appear in white?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

Don’t need to change button textStyle just change child textSytle

OutlinedButton(
                  child: Text(
                    'Next',
                    style: GoogleFonts.inter(
                        textStyle: const TextStyle(
                            fontSize: 20,
                            fontWeight: FontWeight.bold,
                            color: Colors.white)),
                  ),
                  style: ButtonStyle(
                    backgroundColor: MaterialStateProperty.resolveWith((states) {
                      return Colors.indigo;
                    }),
                  ),
                  onPressed: () {
                    // do something
                  })

Preview

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading