Flutterのエラー「The method ‘[]’ can’t be unconditionally invoked because the receiver can be ‘null’.」の意味と対策について紹介します。
「The method ‘[]’ can’t be unconditionally invoked because the receiver can be ‘null’.」の意味
Flutterでデバッグすると以下のようなエラーが出ることがあります。
The method '[]' can't be unconditionally invoked because the receiver can be 'null'. (Documentation) Try making the call conditional (using '?.') or adding a null check to the target ('!').
key: Key(todos[position].id.toString()),
onDismissed: (direction) {
int id = todos[position].id;
String title = todos[position].title.toString();
setState(() {
todos?.removeAt(position);
helper.deleteTodo(id);
getData();
});

【Flutter入門】iOS、Android、Windowsアプリ開発
FlutterによるiOS、Android、Windowsアプリ開発について入門者向けに紹介します。
コメント