Flutter之解决页面底部黄色条纹的方法

用Flutter写页面时,有时页面内容太多,底部会出现黄色条纹。

解决方法:在组件外增加一层ListView即可。

如将代码:

body: Center(
  child: Column(
    mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Image.asset('assets/images/gameover.png',width: 100,height: 100,),
        Container(
          child:Text('游戏结束',style: TextStyle(
            fontSize: 40,
            color: Colors.green
            ),
          ),
          margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 20.0),
        ),
        Container(
          child:Text('您的分数为:${_score}',style: TextStyle(
            fontSize: 40,
            color: Colors.green
            ),
          ),
          margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 50.0),
        ),
        Container(
          child:Text('开始时间为:${_time}',style: TextStyle(
            fontSize: 40,
            color: Colors.green
            ),
          ),
          margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 50.0),
        ),
        Container(
          child:Text('结束时间为:${_endTime}',style: TextStyle(
            fontSize: 40,
            color: Colors.green
            ),
          ),
          margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 50.0),
        ),
        RaisedButton(
          onPressed: (){
            Navigator.pop(context,true);
          },
          textColor: Colors.white,
          clipBehavior: Clip.hardEdge,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(22.0))),
            padding: const EdgeInsets.all(0.0),
            child: Container(
              width: 260,
              height: 44,
              decoration: const BoxDecoration(
                gradient: LinearGradient(
                  colors: <Color>[
                    Color(0xff25D1D1),
                    Color(0xff3BE6AD),
                    Color(0xff20DDAA)
                  ],
                ),
              ),
              padding: const EdgeInsets.all(10.0),
              child: Container(
                alignment: Alignment.center,
                child: Text('重新开始游戏')),
            ),
        )
      ],
  )
)

改成

body: Center(
  child: ListView(
    children:[
      Column(
        mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image.asset('assets/images/gameover.png',width: 100,height: 100,),
            Container(
              child:Text('游戏结束',style: TextStyle(
                fontSize: 40,
                color: Colors.green
                ),
              ),
              margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 20.0),
            ),
            Container(
              child:Text('您的分数为:${_score}',style: TextStyle(
                fontSize: 40,
                color: Colors.green
                ),
              ),
              margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 50.0),
            ),
            Container(
              child:Text('开始时间为:${_time}',style: TextStyle(
                fontSize: 40,
                color: Colors.green
                ),
              ),
              margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 50.0),
            ),
            Container(
              child:Text('结束时间为:${_endTime}',style: TextStyle(
                fontSize: 40,
                color: Colors.green
                ),
              ),
              margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 50.0),
            ),
            RaisedButton(
              onPressed: (){
                Navigator.pop(context,true);
              },
              textColor: Colors.white,
              clipBehavior: Clip.hardEdge,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(22.0))),
                padding: const EdgeInsets.all(0.0),
                child: Container(
                  width: 260,
                  height: 44,
                  decoration: const BoxDecoration(
                    gradient: LinearGradient(
                      colors: <Color>[
                        Color(0xff25D1D1),
                        Color(0xff3BE6AD),
                        Color(0xff20DDAA)
                      ],
                    ),
                  ),
                  padding: const EdgeInsets.all(10.0),
                  child: Container(
                    alignment: Alignment.center,
                    child: Text('重新开始游戏')),
                ),
            )
          ],
      )
    ]
  )
)

效果为:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值