Hello I try to pass image by constructor. But I don't want to add 'required' , because I don't need it in a whole list
Whole error - 'The parameter 'image' can't have a value of 'null' because of its type, but the implicit default value is 'null'. Try adding either an explicit non-'null' default value or the 'required' modifier'
the code where I create the constructor
class LvPopup extends StatelessWidget {
final String title;
final String users_info;
final String image;
LvPopup({
super.key,
required this.title,
required this.users_info,
this.image,
});
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 10),
Column(
children: [
Row(
children: [
Text(
title,
style: TextStyle(color: PaidworkColors.lightTxtColor),
),
],
),
SizedBox(
height: 5,
),
Row(
children: [
Image.asset(image),
Padding(
padding: const EdgeInsets.all(5.0),
child: Text(
users_info,
),
),
],
)
],
)
],
),
);
}
}
and here is the code where I try to pass
LvPopup( image: 'assets/images/blue_dot.png', users_info: "In the process", title: 'Status', ),
I tried to add an question mark like this 'final String? image; ', and then in the image.asset(image as String) , then this error above disappear , and there is a new one 'Type Null is not a subtype of type 'string' in type cast'.