'Undefined name 'context' FLUTTER

lib/screens/Menu/DataNasabah/datanasabah.dart:124:17: Error: The getter 'context' isn't defined for the class 'NasabahDataTableSource'.

  • 'NasabahDataTableSource' is from 'package:flutter_auth/screens/Menu/DataNasabah/datanasabah.dart' ('lib/screens/Menu/DataNasabah/datanasabah.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'context'. context, ^^^^^^^

how to solve this problem?

My Source Code :

class NasabahDataTableSource extends DataTableSource {
  NasabahDataTableSource({this.userData});
  final List<Nasabah> userData;

  @override
  DataRow getRow(int index) {
    return DataRow.byIndex(
      index: index,
      cells: [
        DataCell(Align(
            alignment: Alignment.center,
            child: Text(
              "${userData[index].id}",
            ))),
        DataCell(Align(
          alignment: Alignment.center,
          child: Text("${userData[index].nama_debitur}"),
        )),
        DataCell(
          FlatButton(
            child:
            Icon(
              Icons.chevron_right,
              color: Colors.red,
            ),
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => DetailNasabah(
                    nasabah: userData[index],
                  ),
                ),
              );
            },
          ),
        ),
      ],
    );
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source