Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid Constant Value Text Flutter Google Fonts

I am having Text which i am styling with Google fonts and is working okay but when i add const before Text i get Invalid Constant Value Error

Below is how i have implemented without const


Text(
    'Voila',
     style: GoogleFonts.dawningOfANewDay(fontSize: 30),
),

Below is how i have tried implementing with const


const Text(
        'Voila',
         style: GoogleFonts.dawningOfANewDay(fontSize: 30),
),

Below is how i have tried making google fonts constant but the error still persists


const Text(
              'Voila',
              style: const GoogleFonts.dawningOfANewDay(fontSize: 30),
            )

like image 382
Emmanuel Njorodongo Avatar asked May 12 '26 12:05

Emmanuel Njorodongo


1 Answers

You have to remove const from your code because constant values are expected to be hard coded but the font style or font family you are using is coming dynamically to const won't allow this.

Text(
         'Voila',
         style: const GoogleFonts.dawningOfANewDay(fontSize: 30),
     )
like image 145
Diwyansh Avatar answered May 14 '26 11:05

Diwyansh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!