I have an application. I've added a page to my app and that page will have product information. I was also able to redirect to the page and show the information on that page. I want to put the name of the product in the title value of the SliverAppBar
. The product name is written in the productName
variable.
But I can't enter a variable in the SliverAppBar
's title
value. When trying to login I get this error:
Evaluation of this constant expression throws an exception.dart(const_eval_throws_exception)
A value of type 'Null' can't be assigned to a parameter of type 'String' in a const constructor.
Try using a subtype, or removing the keyword 'const'.dartconst_constructor_param_type_mismatch
Avoid using braces in interpolation when not needed.dartunnecessary_brace_in_string_interps
Invalid constant value.
Codes:
child: CustomScrollView(
slivers: <Widget>[
const SliverAppBar(
pinned: true,
expandedHeight: 250.0,
flexibleSpace: FlexibleSpaceBar(
title: Text("Product ${productName}"),
),
),
// ...
How can I solve this problem? Thanks in advance for your help.
CodePudding user response:
Just remove the const
keyword in front of SliverAppBar
widget
SliverAppBar(
pinned: true,
expandedHeight: 250.0,
flexibleSpace: FlexibleSpaceBar(
title: Text("Product ${productName}"),
),
),