I was just initializing the list, all was woking fine untill i upgraded the flutter as now I'm gettting an error stating as The default 'List' constructor isn't available when null safety is enabled.
. I'm using the get
and get_storage
dependencies.
This is my controller class where I'm getting the error
class TodoController extends GetxController {
var todos = List<Todo>().obs;
@override
void onInit() {
List storedTodos = GetStorage().read<List>('todos');
if (!storedTodos.isNull) {
todos = storedTodos.map((e) => Todo.fromJson(e)).toList().obs;
}
ever(todos, (_) {
GetStorage().write('todos', todos.toList());
});
super.onInit();
}
}
And this is the model class I'm using
class Todo {
String text;
bool done;
Todo({required this.text, this.done = false});
factory Todo.fromJson(Map<String, dynamic> json) =>
Todo(text: json['text'], done: json['done']);
Map<String, dynamic> toJson() => {'text': text, 'done': done};
}```
While initializing the constructor I did get an error stating as ```The parameter 'text' can't have a value of 'null' because of its type, but the implicit default value is 'null'.```
Can i get to know a bit more about this?