Flutter有问题的特定RenderFlex是:RenderFlex#9b4ca relayoutBoundary = up9溢出

时间:2020-07-29 00:06:40

标签: json flutter listview search uisearchbar

我有一个搜索栏,它查询listview(JSON)以从listview(JSON)获取可能关闭的输入文本,由于某种原因,我的水平listview隐藏在右侧,直到我开始在搜索中键入后才显示条文本字段,当它显示时,它不会全部显示,而部分显示,其余列表仍隐藏在设备屏幕的右侧。下面是我的代码,下面是我的屏幕截图:

               Container(
                   height: 120,
                   // width: 150,
                   child: ListView.builder(
                       scrollDirection: Axis.horizontal,
                       // padding: EdgeInsets.all(5.0),
                       itemCount: _notesForDisplay.length+1,
                       itemBuilder: (context, position) {
                         return position == 0 ? _searchBar() : _listItem(position-1);

                       }
                   )),

_listItem(position) {
   return InkWell(

       onTap: (){
         _myFeatureSelection = position.toString();
         debugPrint("myfeat:$_myFeatureSelection");
         //_fetchFeaturePickedList();
         _fetchComment();
       },

       child:Column(
           crossAxisAlignment: CrossAxisAlignment.start,
           children: <Widget>[
             Card(
               semanticContainer: true,
               clipBehavior: Clip.antiAliasWithSaveLayer,
               child: Stack(
                 children: <Widget>[
                   Image.network(_notesForDisplay[position].img_link,
                       width: 120, height: 100, fit: BoxFit.cover),
                   /*Positioned(
                     // top: 16,
                     //left: 140,
                       child: Container(
                         height: 25,
                         width: 80,
                         decoration: BoxDecoration(
                             borderRadius: BorderRadius.circular(5.0),
                             color: Colors.black, //Color(0xff0F0F0F),
                             boxShadow: [
                               BoxShadow(
                                 color: Colors.black.withOpacity(0.3),
                               )
                             ]),
                         child: Center(
                           child: Text(
                             _notesForDisplay[position].title,
                             style: TextStyle(color: Colors.white),
                           ),
                         ),
                       ))*/
                 ],
               ),
               shape: RoundedRectangleBorder(
                   borderRadius: BorderRadius.circular(5.0)),
               elevation: 5,
               //margin: EdgeInsets.all(10),
             ),
             // _FeatureText(featurePhoto.title,16),
             //_FeatureText(featurePhoto.subtitle,12),
           ]));}


 _searchBar() {
   return
     Container(
         width: 240,
         child: Align(
           alignment: Alignment.center,
           child: TextField(
             //controller: searchController,
             cursorColor: Colors.white,
             style: TextStyle(color: Colors.white,fontSize: 12,
                 fontFamily: 'Montserrat'),
             decoration: InputDecoration(
               border: InputBorder.none,
               prefixIcon: Icon(
                 Icons.search,
                 color: Colors.white,
                 size: 15,
               ),
               hintStyle: TextStyle(
                   color: Colors.white,
                   fontSize: 12,
                   fontFamily: 'Montserrat'),
               //alignLabelWithHint: true,
               hintText: "Search...",//contentPadding: EdgeInsets.only(top: 2),
             ),

             onChanged: (text) {
               text = text.toLowerCase();
               setState(() {
                 _notesForDisplay = feature.where((note) {
                   var noteTitle = note.title.toLowerCase();
                   return noteTitle.contains(text);
                 }).toList();
               });
             },


           ),
         ));

 }

enter image description here

enter image description here

0 个答案:

没有答案