When I run my code, I get the following error message:
The parameter 'name' 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.
Here's my code:
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'checkbox.dart';
class TodoItem extends StatefulWidget {
final String name;
final bool? isActive;
const TodoItem({Key? key, this.name, this.isActive}) : super(key: key);
@override
_TodoItemState createState() => _TodoItemState();
}
class _TodoItemState extends State<TodoItem> {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
widget.name,
style: TextStyle(fontSize: 17, color: Colors.grey),
),
Check(
isActive: widget.isActive,
)
],
);
}
}
I tried to solve it with the responses to my last question but that didn't seem to work because apparently Strings are non-nunnable in Dart, even with a "?" besides them.