我正在颤抖,我只是一个初学者。我有多个列表,希望最终将其放入抽屉的菜单中,但是我在视觉上有问题。
我附了一张图片。当您单击标题以下拉列表时,标题本身就会消失。看来这不是我在互联网上看到的其他教程的默认行为。
有人可以帮我吗?
我的代码如下:
package main
import (
"fmt"
"math/rand"
)
const (
ROCK int = iota
PAPER
SCISSORS
)
type Choice struct {
Who int //0 you 1 your opponent
Guess int
}
//Win returns true if you win.
func Win(you, he int) bool {
...
}
func Opponent(guess chan Choice, please chan struct{}) {
for i := 0; i < 3; i++ {
<-please
choice := rand.Intn(3)
who := 1
guess <- Choice{who, choice}
please <- struct{}{}
}
}
func GetChoice(you, he int) int {
...
}
var Cheat func(guess chan Choice) chan Choice = func(guess chan Choice) chan Choice {
new_guess := make(chan Choice)
// go func() {
for i := 0; i < 3; i++ {
g1 := <-guess
g2 := <-guess
if g1.Who == 0 {
choice := GetChoice(g1.Guess, g2.Guess)
new_guess <- g2
new_guess <- Choice{g1.Who, choice}
} else {
choice := GetChoice(g2.Guess, g1.Guess)
new_guess <- g1
new_guess <- Choice{g2.Who, choice}
}
}
// }()
fmt.Println("...")
return new_guess
}
func Me(guess chan Choice, please chan struct{}) {
for i := 0; i < 3; i++ {
<-please
choice := rand.Intn(3)
who := 0
guess <- Choice{who, choice}
please <- struct{}{}
}
}
func Game() []bool {
guess := make(chan Choice)
//please sync 2 goroutines.
please := make(chan struct{})
go func() { please <- struct{}{} }()
go Opponent(guess, please)
go Me(guess, please)
guess = Cheat(guess)
var wins []bool
for i := 0; i < 3; i++ {
g1 := <-guess
g2 := <-guess
win := false
if g1.Who == 0 {
win = Win(g1.Guess, g2.Guess)
} else {
win = Win(g2.Guess, g1.Guess)
}
wins = append(wins, win)
}
return wins
}
func main() {
win := Game()
fmt.Println(win)
}
flutter app missing title when clicked
这是我的main.dart文件
import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.white),
title: Text(
'Home',
style: TextStyle(color: Colors.white),
),
),
body: new ListView.builder(
itemBuilder: (BuildContext context, int index) {
return new StuffInTiles(listofTiles[index]);
},
itemCount: listofTiles.length,
),
);
}
}
class StuffInTiles extends StatelessWidget {
final MyTile myTile;
StuffInTiles(this.myTile);
@override
Widget build(BuildContext context) {
return _buildTiles(myTile);
}
Widget _buildTiles(MyTile t) {
if (t.children.isEmpty) return new ListTile(title: new Text(t.title));
return new ExpansionTile(
key: new PageStorageKey<MyTile>(t),
title: new Text(t.title),
children: t.children.map(_buildTiles).toList(),
);
}
}
class MyTile {
String title;
List<MyTile> children;
MyTile(this.title, [this.children = const <MyTile>[]]);
}
List<MyTile> listofTiles = <MyTile>[
new MyTile('Animals', <MyTile>[
new MyTile('Dogs', <MyTile>[new MyTile('dog one '), new MyTile('dog two')])
])
];
我不明白的一件事是,当我将Homepage构建小部件包装到Material App中时,它可以工作,但我不认为您应该这样做
请注意,main.dart文件将加载登录页面,然后登录页面将加载首页。
如果您在Material App中将HomePage添加到主页,将无法正常工作!
答案 0 :(得分:1)
我找到了自己的答案。当您开始时,最好不要对您不了解的事情胡闹。我有
accentColor: Colors.white,
添加到我的主题数据中,使其在其后面的白色中消失。 抱歉,愚蠢的错误