How to I solve this error (18022): Closure: () => Null

How to I solve this error (18022): Closure: () => Null

我收到此错误:flutter (18022):关闭:() => Null。我在 ItemsCarWidget class 中创建了构造函数变量“function onDeleteFonction”。然后我从 WordListPage class 得到了我的构造函数。但是我无法访问该功能并且出现错误。我该如何解决这个错误?我无法 delete.How 解决这个错误?

代码在这里:

ItemsWidgetCart.dart

class ItemCard extends StatefulWidget {
 Word? word; 
TextEditingController input1;
 TextEditingController input2;
 Function in DeletePress; 
Function? onEditPress;
İtemsWidgetCart.dart
class ItemCard extends StatefulWidget {
  Word? word;
  TextEditingController input1;
  TextEditingController input2;
  Function onDeletePress;
  Function? onEditPress;

  ItemCard(
      {this.word,
        required this.input1,
        required this.input2,
         required this.onDeletePress,
         this.onEditPress});

  @override
  _ItemCardState createState() => _ItemCardState();
}

class _ItemCardState extends State<ItemCard> {
  final DatabaseHelper dbManager = new DatabaseHelper();

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Card(
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    'İngilizce: ${widget.word!.wordEn}',
                    style: TextStyle(fontSize: 15),
                  ),
                  Text(
                    'Türkçe: ${widget.word!.wordTr}',
                    style: TextStyle(
                      fontSize: 15,
                    ),
                  ),
                ],
              ),
              Row(
                children: [
                  CircleAvatar(
                    backgroundColor: Colors.white,
                    child: IconButton(
                      onPressed:()=> widget.onEditPress,
                      icon: Icon(
                        Icons.edit,
                        color: Colors.blueAccent,
                      ),
                    ),
                  ),
                  SizedBox(
                    width: 15,
                  ),
                  CircleAvatar(
                    backgroundColor: Colors.white,
                    child: IconButton(
                      onPressed: () {
                        widget.onDeletePress;
                        print("tıklandı word page");
                        print(widget.onDeletePress);
                      } ,
                      icon: Icon(
                        Icons.delete,
                        color: Colors.red,
                      ),),) ],),],),),),);}}

WordListPage.dart

import 'package:your_research_translation/widgets/itemCardWidget.dart';
import 'package:your_research_translation/utils/databasehelper.dart';
class WordListPage extends StatefulWidget {
  const WordListPage({Key? key}) : super(key: key);

  @override
  _WordListPageState createState() => _WordListPageState();
}


class _WordListPageState extends State<WordListPage> {
  late Word word;
  late List<Word> wordList;
  final DatabaseHelper db= new DatabaseHelper();
  TextEditingController input1 = TextEditingController();
  TextEditingController input2 = TextEditingController();
  bool isLoading = false;
  Future refreshNotes() async {
  setState(() => isLoading = true);

  this.wordList = await db.getWordList();

  setState(() => isLoading = false);
}
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:  FutureBuilder(
        future: db.getWordList(),
    builder: (context, AsyncSnapshot snapshot) {
    if (snapshot.hasData){
    wordList = snapshot.data;
    return ListView.builder(
    itemCount: wordList.length,
    itemBuilder: (context, index) {
    Word _word = wordList[index];
    return ItemCard(

    word: _word,
    input1: input1,
    input2: input2,
    onDeletePress:() => db.deleteWord(_word),
    });},;
    } return Center(child: CircularProgressIndicator(),);
    }), ); }}

databaseHelper.dart

import 'dart:async';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:your_research_translation/models/word.dart';


class DatabaseHelper{
  late Database _database;
  Future openDb() async {
    _database = await openDatabase(join(await getDatabasesPath(), "word.db"),
        version: 1, onCreate: (Database db, int version) async {
          await db.execute(
            "CREATE TABLE word(id INTEGER PRIMARY KEY autoincrement, wordEn TEXT, wordTr TEXT)",
          );
        });
    return _database;
  }
  Future<int> insertWord(Word word) async {
    await openDb();
    return await _database.insert('word', word.toJson());
  }
  Future<List<Word>> getWordList() async {
    await openDb();
    final List<Map<String, dynamic>> maps = await _database.query('word');

    return List.generate(maps.length, (i) {
      return Word(
          id: maps[i]['id'],
          wordEn: maps[i]['wordEn'],
          wordTr: maps[i]['wordTr']);
    });
    
  }
  Future<int> updateWord(Word word) async {
    await openDb();
    return await _database.update('word', word.toJson(),
        where: "id = ?", whereArgs: [word.id]);
  }
  Future<void> deleteWord(Word word) async {
    await openDb();
     await _database.delete('word', where: "id = ?", whereArgs: [word.id]);
    getWordList();
  }

}

这不是对函数的调用:

widget.onDeletePress;

为了调用一个函数,你应该使用:

widget.onDeletePress();

但是如果你只是使用那个函数会更干净:

onPressed: widget.onDeletePress,