I have a problem and it is with respect to the content of the SnackBar. I created a class where it contains the following:
class ActionSuccessSnackBar extends StatelessWidget {
const ActionSuccessSnackBar({
Key key,
this.isCreation,
this.name,
}) : super(key: key);
final bool isCreation;
final String name;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Container(
child: Text(
name,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
Container(
child: Text(
isCreation
? Text("created")
: Text("updated"),
),
),
],
);
}
}
This class I call it in a SnackBar as content (in the parent widget), and it shows it in the following example:
Code :
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
duration: Duration(seconds: 2),
content: ActionSuccessSnackBar(
name: "hello",
isCreation: false,
),
backgroundColor: Colors.green,
));
However, when I go to the main menu (pop) I get the following error:
Any idea about this problem? If I remove the class that I created and just put a text, it works, same if I put the row in the content without the class it works, but that is not what I want.