这是Main.dart
import 'package:Flutter/material.dart';import 'package:url_launcher/url_launcher.dart';import 'dart:async' show Future;import 'package:Flutter/services.dart' show rootBundle;import 'dart:convert';import 'package:emas_app/model/accounts_model.dart';Future<String> _loadAsset() async{ return await rootBundle.loadString('Assets/accounts.Json');}Future<Accounts> loadAccounts() async{ final response = await _loadAsset(); final JsonResponse = Json.decode(response); Accounts accounts = new Accounts.fromJson(JsonResponse); return accounts;}class ProvIDerList extends StatefulWidget { @overrIDe ListState createState() { return new ListState(); }}class ListState extends State<ProvIDerList> { @overrIDe Widget build(BuildContext context) { Widget newbody = new ExpansionTile( Title: new Text("State name"),children: <Widget>[ new FutureBuilder<Accounts>( future: loadAccounts(),builder: (context,snapshot){ if(snapshot.hasData){ return new ListVIEw.builder( itemCount: snapshot.data.accountinfo.length,itemBuilder: (context,index){ String username = snapshot.data.accountinfo[index].name; String address = snapshot.data.accountinfo[index].street; String lat = snapshot.data.accountinfo[index].coordinates.lat; String lng = snapshot.data.accountinfo[index].coordinates.lng; return new ListTile( Title: new Text(username),trailing: new Row( mainAxisSize: MainAxisSize.min,mainAxisAlignment: MainAxisAlignment.end,children: <Widget>[ new Iconbutton( icon: Icon(Icons.info),onpressed: null ),new Iconbutton( icon: Icon(Icons.directions),onpressed: null ) ],) ); }); }else{ return new Center( child: new CircularProgressIndicator(),); } }) ]); return new Scaffold( appbar: new Appbar(Title: new Text("ProvIDers")),body: newbody ); }}
这是显示扩展的ExpansionTile为空的输出:
这是错误抓住:
I/Flutter ( 6305): Vertical vIEwport was given unbounded height.I/Flutter ( 6305): VIEwports expand in the scrolling direction to fill their container.In this case,a verticalI/Flutter ( 6305): vIEwport was given an unlimited amount of vertical space in which to expand. This situationI/Flutter ( 6305): typically happens when a scrollable Widget is nested insIDe another scrollable Widget.
我已经尝试了我可以在Stack Overflow中找到的所有可能的解决方案,通过使用Expanded或Flexible包装ListVIEw.builder但它不起作用.关于如何解决这个问题的任何想法?
解决方法 有两种解决方案:>使用ListVIEw的shrinkWrap属性
new ListVIEw.builder( shrinkWrap: true,itemCount: ...
原因:
在您的情况下,ListVIEw位于ExpansionTile中. ExpansionTile将展示扩展并展示有多少孩子.当ListVIEw放置在ExpansionTile(无界约束小部件)中时,ListVIEw将扩展到scrollDirection中的最大大小.根据文档,
If the scroll vIEw does not shrink wrap,then the scroll vIEw will expandto the maximum allowed size in the [scrollDirection]. If the scroll vIEwhas unbounded constraints in the [scrollDirection],then [shrinkWrap] mustbe true.
>使用SizedBox为ListVIEw提供固定高度.
SizedBox(height: 200.0,child: new ListVIEw.builder(...))总结
以上是内存溢出为你收集整理的dart – 颤振垂直视口无界高度误差全部内容,希望文章能够帮你解决dart – 颤振垂直视口无界高度误差所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)