Hello there!
I'm having a problem when trying to use an instance of SvgPicture.asset as the Icon parameter of the BottomNavigationBarItem widget.
Here is the code:
Widget dumbbellIcon =
SvgPicture.asset('assets/icons/Dumbbell.svg');
Widget build(BuildContext context) {
return Scaffold(
...,
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: dumbbellIcon,
),
],
),
);
}
The errors are:
Invalid constant value.dart(invalid_constant)
The values in a const list literal must be constants.
Try removing the keyword 'const' from the list literal.dart(non_constant_list_element)
I just can't get it to work!
Thank you very much for your work (:
Try const Widget dumbbellIcon =
Thank you for such a quick answer Dan!
I tried it already :/
It throws this:
The constructor being called isn't a const constructor.
Try using 'new' to call the constructor.dart(const_with_non_const)
Const variables must be initialized with a constant value.
Try changing the initializer to be a constant expression.
Ahh in that case you have to take const off the list of bottomnavigwtionbaritems
Most helpful comment
Ahh in that case you have to take const off the list of bottomnavigwtionbaritems