Error passing value to Java - null check operator used on a null value

Viewed 28

I'm trying to pass class code through a java communication channel like this:

onImageCapture() async {
    try {
      await platform_foto.invokeMethod('onImageCapture', {
        "codigo": widget.cod
      });
    } on Exception catch (e) {}
  }

but I get:

null check operator used on a null value

In the same class, I can display class code normally like this:

Text(
"Cód. Aula: " + widget.codigo.toString(),
 style: TextStyle(
 fontSize: 15,
 fontWeight: FontWeight.normal)),

I am stating it this way:

class Monitoramento extends StatefulWidget {
  final int cod;
 .
 .
 .
  const Monitoramento(
      {this.cod,.. ..., ...});

  @override
  MonitoramentoState createState() => new MonitoramentoState();
}

What am I doing wrong? In one point of the code it works, but in another it doesn't? Should I switch to null security?

I'm using the version: Flutter 2.2.3

I appreciate any comments!

0 Answers
Related