Reputation: 2582
I write the following widget:
class Bottombar extends StatelessWidget {
final double padding;
Bottombar({@required this.padding});
@override
Widget build(BuildContext context) {
return new Container(
padding: const EdgeInsets.all(padding), child: new Text('Test'),);
}
}
However, it reports compiling error that the padding parameter must be constant expressions. Why cannot use the final member field as the parameter of widget padding? For what reason?
The flutter version is beta 0.3.1
Upvotes: 5
Views: 2055
Reputation: 5605
The problem is you're using const
to create the EdgeInsets
but then passing a variable padding
.
Remove const
and it should work.
Upvotes: 13