在SingleChildScrollView中无法向下滚动

时间:2020-06-23 04:27:59

标签: flutter dart flutter-layout

这是我的代码:

return Scaffold(
      backgroundColor: Colors.black,
      body: loader ?Loader():SingleChildScrollView(
        physics: BouncingScrollPhysics(),
         child: Column(
           crossAxisAlignment: CrossAxisAlignment.start,
           mainAxisAlignment: MainAxisAlignment.start,
           children: <Widget>[
              /////Add Any widget for example I'm adding container of height 100, it will reduce my last object height by 100//////////////
// I want anything inside this column to be scrollable///////////

           Container(height: 100), ---------This will reduce

             Container(
               height: MediaQuery.of(context).size.height,
               child: ListView.builder(
                   shrinkWrap: true,
                   scrollDirection: Axis.vertical,
                   itemCount: categoriesOnlyList.length,
                   itemBuilder: (context, index1){
                     return Column(
                       crossAxisAlignment: CrossAxisAlignment.start,
                       mainAxisAlignment: MainAxisAlignment.start,
                       children: <Widget>[
                         Center(
                           child: Text(
                             categoriesOnlyList[index1].Name,
                             textAlign: TextAlign.center,
                             style: TextStyle(color: Colors.white),
                           ),
                         ),
                         Container(
                           height: 200,
                           decoration: BoxDecoration(
                             borderRadius: BorderRadius.circular(8),

                           ),
                           child: ListView.builder(
                               itemCount: categoryItemList.length,
                               shrinkWrap: true,// place breakpoint here
                               scrollDirection: Axis.horizontal,
                               itemBuilder:  (context, index){
                             return categoriesOnlyList[index1].Name ==
                                 categoryItemList[index].CategoryName
                                 ? Padding(
                               padding: const EdgeInsets.all(8.0),
                               child: Container(
                                 height: 200,
                                 width: 200,
                                 decoration: BoxDecoration(
                                     borderRadius: BorderRadius.circular(8)),
                                 child: Card(
                                   color: Colors.white,
                                   child: Center(
                                     child: Text(
                                       categoryItemList[index].Name,
                                       style: TextStyle(),
                                       overflow: TextOverflow.ellipsis,
                                     ),
                                   ),
                                 ),
                               ),
                             )
                                 : Container();
                           }),
                         ),
                       ],
                     );



         }),
             ),

           ],
         )
      ),
    );

在此代码中,我能够看到所有具有滚动行为的数据,但是每当我尝试在代码中指示的列中添加任何其他容器或小部件时,它都会减小最后一个项目的大小,使其等于小部件的高度,但是我希望屏幕无限滚动,即每当我向列中添加任何小部件时,它都必须向下滚动并在屏幕上显示小部件。

这是我要附加的屏幕截图。

enter image description here

包装食品的大小减少了一半。

0 个答案:

没有答案