If try to add an imagen in dart-flutter like this, the code may broke
Fo dart version Flutter 3.1.0-0.0.pre.2331
Dart Dart SDK version: 2.17.6
I solve the Fix using this:
class Movie {
String? posterAsset;
//Constructor
Movie({
this.posterAsset,
});
}
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
//imagen
children: <Widget>[
Image(image: AssetImage(movie.posterAsset)),
],
),
//Inicializador
MovieMiddle(this.movie);
@override
Widget build(BuildContext context) {
final bordeSide = BorderSide(
color: Color.fromARGB(20, 255, 255, 255),
width: 1,
);
return Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
//imagen
children: <Widget>[
Image(image: AssetImage(movie.posterAsset!)),
],
),
);
}
}
the problem is how call the image is the object is null-safety how you can see here
image: AssetImage(movie.posterAsset!),
return Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
//imagen
children: <Widget>[
Image(
image: AssetImage(
movie.posterAsset!,
),
fit: BoxFit.cover,
),
],
),
);
The most import is, how manage the image:
Fo dart version
Flutter 3.1.0-0.0.pre.2331
Dart Dart SDK version: 2.17.6