- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试开发一个 flutter 应用程序。这种 flutter 正在为纸牌游戏创建团队。创建团队后,可以通过 统计积分,不用考虑每个人有多少积分。
但是我遇到了一个异常,我知道异常在哪里以及它意味着什么,但我不知道如何解决这个问题。我希望你们中的一些人能帮助我。
这是抛出错误的代码:
import 'package:flutter/material.dart';
class Punktezaehler extends StatefulWidget{
final List<String> spieler_namen;
Punktezaehler(this.spieler_namen);
@override
State<StatefulWidget> createState() => new _Punktezaehler(this.spieler_namen);
}
class _Punktezaehler extends State<Punktezaehler>{
final List<String> spieler_namen;
_Punktezaehler(this.spieler_namen);
List<int> punkteanzahl_teamEins;
List<int> 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: <Widget>[
],
),
body: Container(
child: new Row(
children: <Widget>[
new Column(
children: <Widget>[
new IconButton(
icon: Icon(Icons.exposure_plus_2),
onPressed: () => punkte_hinzuzaehlen(1, 2)
)
],
),
new Column(
children: <Widget>[
//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: <Widget>[
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");
}
}
}
这是错误信息:
══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (26028): The following NoSuchMethodError was thrown while handling a gesture:
I/flutter (26028): The getter 'length' was called on null.
I/flutter (26028): Receiver: null
I/flutter (26028): Tried calling: length
修复后,我又遇到了一个错误:
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (26028): The following assertion was thrown during performResize():
I/flutter (26028): Vertical viewport was given unbounded width.
I/flutter (26028): Viewports expand in the cross axis to fill their container and constrain their children to match
I/flutter (26028): their extent in the cross axis. In this case, a vertical viewport was given an unlimited amount of
I/flutter (26028): horizontal space in which to expand.
最佳答案
punkteanzahl_teamEins 仅被声明。但是没有初始化。所以它抛出空错误。
您应该将值分配给 punkteanzahl_teamEins
作为
List<int> punkteanzahl_teamEins = [1,4,5,7];
或根据要求从父级传递数据。
关于android - Flutter - getter 'length' 在 null 上被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51177294/
我找到了以下代码片段: length = length and length or len(string) 在我看来,这应该等同于: length = length or len(string) 我能
当我使用 numpy.shape() 检查数组的形状时,我有时会得到 (length,1) 有时会得到 (length,)。看起来区别在于列向量与行向量......但它似乎并没有改变数组本身的任何内容
我正在学习 Java,有一个简单的问题。 在设置类的示例中,我看到了这一点: length >= 0 ? length : length * -1 这是什么意思? 谢谢。 最佳答案 这是一种骇人听闻的
我在阅读有关在 Ruby 中重新定义方法有多么容易的文章时遇到了以下问题: class Array alias :old_length :length def length old_l
例如在下面的代码中a和b和c是相等的。 EditText editText; editText = (EditText) findViewById(R.id.edttxt); editText.set
在昨天教授我的 JavaScript 类(class)时,我和我的学生遇到了一些有趣的功能,我认为这些功能可能值得在一个问题和我得出的答案中捕捉到。 在 Chrome 的 JS 控制台中输入 Arra
这个问题在这里已经有了答案: How can I get the size of an array, a Collection, or a String in Java? (3 个回答) 3年前关闭。
这个问题在这里已经有了答案: length and length() in Java (8 个答案) 关闭 6 年前。 我注意到在计算数组的长度时,你会这样写: arrayone.length; 但
console.log(this.slides.length()); 打印 Cannot read property 'length' of undefined.在 setTimeout 为 100
在搜索stackoverflow问题时,我发现了此链接: Error in file.download when downloading custom file。 但是,我的情况有些不同(我认为):
这个问题已经有答案了: Why does R use partial matching? (1 个回答) 已关闭 8 年前。 大家。我刚刚开始使用 swirl 学习 R 编程。 我刚刚了解到seq 。
这个问题已经有答案了: Why does R use partial matching? (1 个回答) 已关闭 8 年前。 大家。我刚刚开始使用 swirl 学习 R 编程。 我刚刚了解到seq 。
这个问题已经有答案了: How can I get the size of an array, a Collection, or a String in Java? (3 个回答) 已关闭 9 年前。
我有一个大数组,其中包含所有类型( bool 值,数组,null,...),并且我正在尝试访问它们的属性arr[i].length,但有些其中显然没有长度。 我不介意那些缺少长度的人是否返回未定义(我
我在对象的属性中有一些文本。我正在测试对象的属性中是否有要显示的文本;如果没有,那么我显示“-”而不是空白。看起来没有什么区别: if (MyObject.SomeText && MyObject.S
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Why is String.length() a method? Java - Array's length
这个问题在这里已经有了答案: obj.length === +obj.length in javascript (4 个答案) 关闭 9 年前。 我一直在读underscore.js源代码并在 _.
#include using std::cout; using std::cin; using std::string; int main(){ cout > name; cout
我正在细读 underscore.js annotated source当我遇到这个时: if (obj.length === +obj.length) {...} 我现在从this stackove
我正在查看 dotnet 运行时中的一些代码,我注意到不是这样写的: if (args.Length > 0) 他们使用这个: if (args is { Length: > 0}) 你知道用第二种方
我是一名优秀的程序员,十分优秀!