NoSuchMethodError : The getter 'title' was called on null. Receiver : null. Tried calling: title. //Anyone please
NoSuchMethodError : The getter 'title' was called on null. Receiver : null. Tried calling: title. //Anyone please
这些是我的一些 todo_detail.dart 代码。请帮我。在调试控制台中显示
The relevant error-causing widget was
TodoDetail
lib/Screens/todo_list.dart:100
When the exception was thrown, this was the stack
#1 TodoDetailState.build
package:todo_list/Screens/todo_detail.dart:35
class TodoDetail extends StatefulWidget {
TodoDetail(this.todo, this.appBarTitle);
final String appBarTitle;
final Todo todo;
@override
State<StatefulWidget> createState() {
return TodoDetailState(this.todo, this.appBarTitle);
}
}
class TodoDetailState extends State<TodoDetail> {
DatabaseHelper helper = DatabaseHelper();
String appBarTitle;
Todo todo;
TextEditingController titleController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
TodoDetailState(this.todo, this.appBarTitle);
@override
Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.headline6;
final Todo todo = ModalRoute.of(context).settings.arguments;
titleController.text = todo.title;
descriptionController.text = todo.description,......
This is the screenshot 在我的物理设备上构建后的错误
Todo
在上面的代码中作为 Widget
参数传递,因此,我们可以通过以下方式访问它:
final Todo todo = widget.todo;
完整代码示例:
class TodoDetailState extends State<TodoDetail> {
DatabaseHelper helper = DatabaseHelper();
String appBarTitle;
Todo todo;
TextEditingController titleController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
TodoDetailState(this.todo, this.appBarTitle);
@override
Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.headline6;
final Todo todo = widget.todo;
titleController.text = todo.title;
descriptionController.text = todo.description;
return Container();
}
}
这些是我的一些 todo_detail.dart 代码。请帮我。在调试控制台中显示
The relevant error-causing widget was
TodoDetail
lib/Screens/todo_list.dart:100
When the exception was thrown, this was the stack
#1 TodoDetailState.build
package:todo_list/Screens/todo_detail.dart:35
class TodoDetail extends StatefulWidget {
TodoDetail(this.todo, this.appBarTitle);
final String appBarTitle;
final Todo todo;
@override
State<StatefulWidget> createState() {
return TodoDetailState(this.todo, this.appBarTitle);
}
}
class TodoDetailState extends State<TodoDetail> {
DatabaseHelper helper = DatabaseHelper();
String appBarTitle;
Todo todo;
TextEditingController titleController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
TodoDetailState(this.todo, this.appBarTitle);
@override
Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.headline6;
final Todo todo = ModalRoute.of(context).settings.arguments;
titleController.text = todo.title;
descriptionController.text = todo.description,......
This is the screenshot 在我的物理设备上构建后的错误
Todo
在上面的代码中作为 Widget
参数传递,因此,我们可以通过以下方式访问它:
final Todo todo = widget.todo;
完整代码示例:
class TodoDetailState extends State<TodoDetail> {
DatabaseHelper helper = DatabaseHelper();
String appBarTitle;
Todo todo;
TextEditingController titleController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
TodoDetailState(this.todo, this.appBarTitle);
@override
Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.headline6;
final Todo todo = widget.todo;
titleController.text = todo.title;
descriptionController.text = todo.description;
return Container();
}
}