Good day, I have been trying the below code:
class SearchMovieCard extends StatelessWidget {
final MovieEntity movie;
const SearchMovieCard({super.key, required this.movie});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => MovieDetailScreen(
movieDetailArguments: MovieDetailArguments(
movie.id,
),
),
),
);
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: Sizes.dimen_16.w.toDouble(),
vertical: Sizes.dimen_2.h.toDouble(),
),
child: Row(
children: [
Padding(
padding: EdgeInsets.all(
Sizes.dimen_8.w.toDouble(),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(
Sizes.dimen_4.w.toDouble(),
),
child: CachedNetworkImage(
imageUrl: '${ApiConstants.BASE_IMAGE_URL}${movie.posterPath}',
width: Sizes.dimen_80.w.toDouble(),
),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
movie.title,
style: Theme.of(context).textTheme.subtitle1,
),
Text(
movie.overview,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.greyCaption,
),
],
),
),
],
),
),
);
}
}
But in my code Text(movie.overview,),
I get the error I wrote in the title. I would be very happy if you help me with the solution of the error.
I’ve tried looking online for articles with this error but it doesn’t fix the error at all. I also asked the same to ChatGPT and it still didn’t fix it.
Usually on the internet they say ?? ""
type this code and it will be fixed. I tried but I keep getting the same error.
3
Answers
Did you try to add double quote to both
title
andoverview
?Add a null check operator (!) into your text variable.
For Example:
usually this happen if the value may be null so you need to fix if the value is null
either use ! to make the movie nullable
or use ?? if null then "" means blank