垂直视口被赋予无限高度。 RenderBox 未布局:RenderViewport#34d12 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Vertical viewport was given unbounded height. RenderBox was not laid out: RenderViewport#34d12 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

我无法使用 listview.builder 列出我的数据。

Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget. If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.

如何在 listview 中使用 listview.builder

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart';
class Profil extends StatefulWidget {
  @override
  _ProfilState createState() => _ProfilState();
}
class _ProfilState extends State<Profil> {
  final List<String> entries = <String>['Privacy', 'Purshase History', 'Help & Support','Settings','Invite a Friend'];
  final  List<Icon> iconsImage =
  [Icon(Icons.privacy_tip),
    Icon(Icons.history),
    Icon(Icons.help),
    Icon(Icons.settings),
  Icon(Icons.person_add_alt)
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title:Text("Profilim",style: TextStyle(fontSize: 20),),backgroundColor: HexColor("#0e2d85"),actions: [
        Container(padding: EdgeInsets.only(right: 15),child: Icon(Icons.exit_to_app)),
      ],),
      body: Container(
        child: Padding(
          padding: const EdgeInsets.only(top:10.0,right: 10),
          child: Column(
            children: [
              Column(children: [
                Row( mainAxisAlignment:MainAxisAlignment.end,children:[IconButton(icon: Icon(FontAwesomeIcons.highlighter), onPressed: (){})] ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
                  child: Row(
                    children: [
                      Stack(children: [
                        Container(
                          height: 150,
                          width: 150,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(80),
                            image: DecorationImage(image: AssetImage("assets/BG.jpg"),fit: BoxFit.cover),
                          ),
                        ),
                              Positioned(
                                  top: 125,
                                  left: 120,
                                  child: Container(
                                    child: CircleAvatar(
                                      child: Icon(
                                        Icons.edit,
                                        color: Colors.yellow,
                                        size: 15,
                                      ),
                                    ),
                                  )),
                      ],
                      ),
                      SizedBox(width: 30,),
                      Column(
                        children: [
                          Text("Salih"),
                          SizedBox(height: 10,),
                          Text("salih@gmail.com"),
                          SizedBox(height: 10,),
                          Container(width:200,child: RaisedButton(onPressed: (){}, color:Colors.yellow[200],child: Text("Upgrade to PRO",style: TextStyle(color: Colors.black),),shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),))
                        ],
                      )
                    ],
                  ),
                )
              ],
              ),
        ListView.builder(
            padding: const EdgeInsets.all(8),
            itemCount: 2,
            itemBuilder: (BuildContext context, int index) {
              return Container(
                height: 20,
                child: Center(child: Text('Entry ${entries[index]}')),
              );
            }
        ),
            ],
          ),
        ),
      )
    );
  }
}

您可以将 Listview.builder 包装在 Expanded 小部件中,让列表视图获取列的上述内容之后留下的 space。 但同样,它只会在 Column 的上述内容之后占用页面上剩余的高度,并且只会在 space 中滚动!