1.

The getter 'length' was called on null.I/flutter ( 6048): receiver: nulli/flutter ( 6048): tried calling: length

Answer»

I am trying to DEVELOP a flutter app. This flutter is creating teams for a card game. After the creation of the team, the points could be COUNTED through the, so that you don't have to think about how many points everybody has.

But I got an exception, where I know where the exception and what it means, but i do not have any clue how i could solve the problem. I HOPE some of you guys could help me.

This is the code where the error is thrown:

import 'package:flutter/material.dart'; class Punktezaehler extends StatefulWidget{ final List spieler_namen; Punktezaehler(this.spieler_namen); @override STATE createState() => new _Punktezaehler(this.spieler_namen); } class _Punktezaehler extends State{ final List spieler_namen; _Punktezaehler(this.spieler_namen); List punkteanzahl_teamEins; List punkteanzahl_teamZwei; @override Widget build(BuildContext context) { var spieler1 = spieler_namen[0].substring(0,3); var spieler2 = spieler_namen[1].substring(0,3); var spieler3 = spieler_namen[2].substring(0,3); var spieler4 = spieler_namen[3].substring(0,3); return new Scaffold( appBar: new AppBar( automaticallyImplyLeading: false, title: new Text("$spieler1 & $spieler2 vs" +" $spieler3 & $spieler4"), actions: [ ], ), body: Container( child: new Row( children: [ new Column( children: [ new IconButton( icon: Icon(Icons.exposure_plus_2), onPressed: () => punkte_hinzuzaehlen(1, 2) ) ], ), new Column( children: [ //new FlatButton(onPressed: () => print(punkteanzahl_teamEins.length), child: new Text("Punkte")), ListView.builder( itemCount: punkteanzahl_teamEins.length, //--> Error is thrown here itemBuilder: (context, index){ return Text(punkteanzahl_teamEins[index].toString()); } ), new Row() ], ), new Column( children: [ new IconButton( icon: Icon(Icons.exposure_plus_2), onPressed: () => punkte_hinzuzaehlen(2, 2) )], ) ], ) ), ); } void punkte_hinzuzaehlen(int team, int nummer){ if (team == 1){ //Team 1 bekommt die Punkte print("Team 1 gets points"); } ELSE if(team == 2){ //Team 2 bekommt die Punkte print("Team 2 gets points"); } } }



Discussion

No Comment Found

Related InterviewSolutions