在 Flutter 中,DropdownButtonFormField的模态列表不断增长以填充一些高度限制,该限制似乎占屏幕的 90%(或者可能,并且更有可能,Container它在其中)。当它达到该限制时,它变得可滚动。是否可以设置该高度限制?
这是我正在使用的代码
Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Container(
padding: EdgeInsets.fromLTRB(5, 5, 5, 5),
child: Form(
child: ListView(
scrollDirection: Axis.vertical,
children: <Widget>[
//other widgets here
DropdownButtonFormField(items: this.dropDownItems),
],
),
)),
);
Run Code Online (Sandbox Code Playgroud) 我正在为折叠游戏制作2D Arraylist板,但现在只是做一个文本表示.我创建了这个板,但是当我尝试用randomChar()填充它时,所有的行都得到相同的随机字符.我究竟做错了什么?
public static void createBoard(int rSize, int cSize) {
ArrayList<Character> row = new ArrayList<Character>();
ArrayList<ArrayList<Character>> board = new ArrayList<ArrayList<Character>>();
for (int c = 0; c < cSize; c++) {
board.add(row);
}
for (int r = 0; r < rSize; r++) {
board.get(r).add(randomChar());
//row.add(randomChar());
// board.get(r).set(r, randomChar());
}
//prints out board in table form
for (ArrayList<Character> r : board) {
printRow(r);
}
System.out.println(board);
}
Run Code Online (Sandbox Code Playgroud)