FieryCat
FieryCat

Reputation: 1889

Flutter - "Invalid constant value" in nested structures

By using a multilingual approach build is failing with a not fully clear error "Invalid constant value". As for the last screen, AppBar is taking a proper title where as body content is failing. Any thoughts? Thanks in advance!

enter image description here

enter image description here

Upvotes: 0

Views: 50

Answers (2)

Delwinn
Delwinn

Reputation: 1019

Since applocalizations provide values that could change over time within the app, it's not a constant value. So, remove the const keyword before Center widget. Your updated code would look like so

 @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(AppLocalizations.of(context)!.title),
    );
  }

Upvotes: 2

VincentDR
VincentDR

Reputation: 709

You need to remove "const" keyword on your Center widget as your localized text is not a const value.

Upvotes: 2

Related Questions