这就是我现在所拥有的,它将滚动但搜索栏保持在顶部.
new Column( children: <Widget>[ new Flexible( child: new Column( children: <Widget>[ new Container( margin: new EdgeInsets.only(left: 4.0,right: 4.0),color: colors.white,child: new Row( children: <Widget>[ new Container( margin: new EdgeInsets.only(left: 8.0,right: 8.0,top: 8.0,bottom: 8.0),child: Icon(Icons.search),),new Container( child: Flexible( child: new TextFIEld( onChanged: (String text) { setState(() { _searchController.text = text; }); },decoration: new inputdecoration.collapsed(hintText: 'Search...'),controller: _searchController,) ),],new Flexible( child: new StreamBuilder( stream: stgdocument.collection('people').orderBy('scroll').snapshots(),builder: (context,snapshot) { if (!snapshot.hasData) return const Text('Loading...'); _getMembers(snapshot); return new GrIDVIEw.builder( //itemCount: snapshot.data.documents.length,itemCount: _searchedMemberList.length,grIDDelegate: new SliverGrIDDelegateWithFixedCrossAxisCount(crossAxisCount: 2),itemBuilder: (context,index) => _buildPeopleCards(context,_searchedMemberList[index]),//_buildPeopleCards(context,snapshot.data.documents[index]) ); } ) ),)解决方法 您可以使用下面的结构创建一个包含多个子项的可滚动 ListView,其中一个为 GridView.要为ListVIEw中的所有元素启用滚动,需要将其参数物理设置为 NeverScrollablePhysics.
- ListVIEw - Container // your searchbar would go here - GrIDVIEw // physics: NeverScrollablePhysics - Children
这是一个完整的代码示例:
import 'package:Flutter/material.dart';import 'package:cached_network_image/cached_network_image.dart';voID main() => runApp(MyApp());class MyApp extends StatelessWidget { @overrIDe Widget build(BuildContext context) { return MaterialApp( theme: themeData(),home: Scaffold( body: ListVIEw( children: <Widget>[ Container( color: colors.red,height: 50.0,GrIDVIEw.count( physics: NeverScrollableScrollPhysics(),crossAxisCount: 3,shrinkWrap: true,children: generateNumbers().map((int i) { return Text(i.toString()); }).toList(),) ],); } List<int> generateNumbers() => List<int>.generate(30,(i) => i + 1);}
结果如下:
总结以上是内存溢出为你收集整理的颤动在列表视图中显示gridview全部内容,希望文章能够帮你解决颤动在列表视图中显示gridview所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)