flutter - 如何使用未来的构建器添加返回两个小部件
问题描述
我想显示两个小部件,比如一个文本,然后是一个表格,它们都包含来自 api 的数据。我正在使用堆栈,我为表格创建了一个单独的方法。这是代码
Container(
padding: EdgeInsets.fromLTRB(15, 470, 0, 0),
child:SingleChildScrollView(
scrollDirection: Axis.vertical,
child: FutureBuilder(
future: _getRecord(),
builder: (BuildContext context, AsyncSnapshot<List<History>> snapshot) {
// Check if the data has been received.
if (snapshot.hasData) {
// Return the widget and provide the received data.
if(historyList.length!=0){
return Stack(children:<Widget>[
Expanded(
child: ListView.builder(
itemCount: snapshot.data.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return ListTile(subtitle:Text(snapshot.data[index].date));})),// it is not displaying this line
SizedBox(height: 30,),
attendanceHistory(snapshot.data)
]);
// return attendanceHistory(snapshot.data);
}
}
attendanceHistory(snapshot.data)
此行显示带有数据的表格,但字幕不起作用
请帮助如何做到这一点
解决方案
推荐阅读
- reactjs - React Native createBottomTabNavigator 与间距
- arrays - How should I selectively sum multiple axes of an array?
- html - HTML / CSS - Position Sticky and transform without resizing viewport
- istio - 为什么 Istio Mixer 使用两个部署分别进行遥测收集和策略检查?
- codeigniter - 如何在那里使用 URI 段路由 Codeigniter
- angular6 - Angular 6 - 存储全局变量和数据
- junit - 使用 H2 数据库进行单元测试
- haskell - 在 Haskell 中使用增量不同的参数运行函数 n 次
- shiny - 在 Shinyapps 上使用 rJava 包
- powershell - 人类可读的字节大小的显示如何工作?