error: The values in a const list literal must be constants. Flutter
error: The values in a const list literal must be constants. Flutter
can any one tell me why is there an error. im a beginner in flutter. can any one help.
这是代码,错误在按下函数上。
Expanded(
child: TextButton(
onPressed: () {},
child: Padding(
padding: EdgeInsets.all(16.0),
child: Image(
image: AssetImage('images/dice1.png'),
)
),
),
),
错误:
error: Invalid constant value. (invalid_constant at line 3)
error: The values in a const list literal must be constants. (non_constant_list_element at line 3)
如果您不使用固定值,请不要使用 const 关键字。 Flutter 使用 const 关键字作为 widget 永远不会重建的指示符,因为它将在编译时评估,并且只会评估一次。
can any one tell me why is there an error. im a beginner in flutter. can any one help.
这是代码,错误在按下函数上。
Expanded(
child: TextButton(
onPressed: () {},
child: Padding(
padding: EdgeInsets.all(16.0),
child: Image(
image: AssetImage('images/dice1.png'),
)
),
),
),
错误:
error: Invalid constant value. (invalid_constant at line 3)
error: The values in a const list literal must be constants. (non_constant_list_element at line 3)
如果您不使用固定值,请不要使用 const 关键字。 Flutter 使用 const 关键字作为 widget 永远不会重建的指示符,因为它将在编译时评估,并且只会评估一次。