Home > OS >  Flutter - "Invalid constant value" in nested structures
Flutter - "Invalid constant value" in nested structures

Time:11-24

By using enter image description here

enter image description here

CodePudding user response:

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

CodePudding user response:

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),
    );
  }
  • Related