本文介绍了列表最后一项上的FloatingActionButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 FloatingActionButton 的可滚动列表.我想使列表在 FloatingActionButton 之前完成,因为列表的最后一项不再可见(FAB在列表项上方)

I have a scrollable list with a FloatingActionButton. I would like to make the list to finish before the FloatingActionButton because last item of list isn't visible anymore(FAB it's over list item)

return Scaffold(
    body: ListView(
      scrollDirection: Axis.vertical,
      controller: _scrollController,
      shrinkWrap: true,
      children: <Widget>[
        _buildUpcomingExpansionTileEvents(myUpcomingEvents),
        _buildPastExpansionTileEvents(myPastEvents),
      ],
    ),
    floatingActionButton: UnicornDialer(
        parentButtonBackground: Colors.blue,
        orientation: UnicornOrientation.VERTICAL,
        parentButton: Icon(OMIcons.add),
        childButtons: childButtons));

如何更改列表以保留一个空项目?或对此问题的最佳解决方案是什么?

How could I change my list to finish with one empty item? Or what's the best solution to this problem?

推荐答案

FloatingActionButton 的大小为非迷你的 56 40 mini,因此您可以在 ListView 中使用 padding ,例如:

FloatingActionButton has size of 56 for non-mini and 40 for mini, so what you can do is use padding in ListView like:

ListView(
  padding: EdgeInsets.only(bottom: 56), // if you have non-mini FAB else use 40
  // ...
),

这篇关于列表最后一项上的FloatingActionButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-11 02:27