please help me solve the following problem.
This part of my code:
class MeditationCard extends StatelessWidget {
const MeditationCard({
required this.title,
required this.image,
this.route});
final String title;
final String image;
final String route;
...
I need the route variable as optional, but when I remove the flag, I get an error and ask me to make the variable mandatory.
Tried different approaches but didn’t work for me
This alert dialog
The parameter ‘route’ can’t have a value of ‘null’ because of its
type, but the implicit default value is ‘null’.
>Solution :
This happened because of null safety check.In order to set nullable variable, you should use ?, try this:
final String? route;