在安卓模拟器上活动入口最后一排不显示报错溢出38像素: A RenderFlex overflowed by 38 pixels on the bottom.

来源:12-13 活动入口实现【实战应用】

慕丝4406464

2019-04-07

写回答

2回答

CrazyCodeBoy

2019-04-09

问题出在你为Container限制了高度64,将它去掉就好了:

@override
Widget build(BuildContext context) {
  return Container(
    height: 64,
    decoration: BoxDecoration(
        color: Colors.white, borderRadius: BorderRadius.circular(6)),
    child: Padding(
      padding: EdgeInsets.all(7),
      child: _items(context),
    ),
  );
}
//改成
@override
Widget build(BuildContext context) {
  return Container(
    decoration: BoxDecoration(
        color: Colors.white, borderRadius: BorderRadius.circular(6)),
    child: Padding(
      padding: EdgeInsets.all(7),
      child: _items(context),
    ),
  );
}


可参考:https://git.imooc.com/coding-321/flutter_trip/commit/144914a71a0f2da457d6c63575207eef0cefd4b3


1
3
慕丝4406464
回复
CrazyCodeBoy
谢谢老师
2019-04-11
共3条回复

慕丝4406464

提问者

2019-04-10

//img.mukewang.com/szimg/5cadaf50000170f004860769.jpg

import 'package:flutter/material.dart';
import 'package:flutter_app/model/common_model.dart';
import 'package:flutter_app/webView/webview.dart';
import 'package:path/path.dart';

class SubNav extends StatelessWidget{
 final List<CommonModel> subNavList;
 final String name;
 const SubNav({Key key,@required this.subNavList,this.name});
 @override
 Widget build(BuildContext context) {
   return Container(
     height: 64,
       decoration: BoxDecoration(
         color: Colors.white,
         borderRadius: BorderRadius.circular(6)
       ),
     child: Padding(padding: EdgeInsets.all(7),
       child: _items(context),
     ),
   );
 }
 _items(BuildContext context){
   if(subNavList==null)return null;
   List<Widget> items = [];//定义一个数组用于接收创建的item
   subNavList.forEach((model){
     items.add(_item(context,model));
   });
   //计算出第一行显示的数量
   int separate = (subNavList.length / 2 +0.5).toInt();

   return Column(
     children: <Widget>[
       //第一行显示
         Row(//排列一行用Row包裹
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
           children: items.sublist(0,separate),
         ),
       //第二行显示
       Padding(
         padding: EdgeInsets.only(top: 10),
         child: Row(
           mainAxisAlignment: MainAxisAlignment.spaceBetween,
           children: items.sublist(separate,subNavList.length),
         ),
       )
     ],
   );
 }
 Widget _item(BuildContext context,CommonModel model){
   return Expanded(
     flex: 1,
     child: GestureDetector(//添加点击效果用GestureDetector包裹一下
       onTap: (){
         //跳转到webView的h5页面
         Navigator.push(context,
             MaterialPageRoute(builder: (context)=>
             //引入自定义的WebView
             WebView(
                 url: model.url,
                 statusBarColor:model.statusBarColor,
                 hideAppBar:model.hideAppBar
             )
             )
         );
       },
       child: Column(
         children: <Widget>[
           Image.network(
             model.icon,
             width: 18,
             height: 18,
           ),
           Padding(
               padding: EdgeInsets.only(top: 3),
               child: Text(
                 model.title,
                 style: TextStyle(fontSize: 12),
               )
           )

         ],
       ),
     ),
   );
 }
}

0
0

Flutter从入门到进阶 实战携程网App 一网打尽核心技术

解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。

4788 学习 · 3274 问题

查看课程