【问题标题】:How to Scroll a `child: Column` on Flutter using AlwaysScrollableScrollPhysics如何使用 AlwaysScrollableScrollPhysics 在 Flutter 上滚动“子项:列”
【发布时间】:2019-02-24 17:49:26
【问题描述】:

我的目标是在默认情况下限制过度滚动的页面上实现滚动。这是由flutter 上的AlwaysScrollableScrollPhysics 类实现的,但我无法找到有关其实现的适当资源。

以下是我想要实现此功能的其中一个页面的代码 - 但请注意,我在滚动功能方面遇到了复杂问题。我试过Scrollable 和SingleChildScrollView,两者都给出错误“位置参数太多”)。据我所知,问题在于我正在使用列来实现这一点,这不是正确的方式。

任何关于整个问题的帮助或指示将不胜感激。

body: Container(
        padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
        child: Column(
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Header(),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
              child: Text(
                'Some Exam',
                style: TextStyle(
                    fontSize: 15,
                    fontFamily: 'GoogleMedium',
                    color: Colors.black54),
              ),
            ),
            Subject(
              iconData: OMIcons.supervisorAccount,
              title: 'English',
              msg: 'Difficulty Level: Easy',
              count: '145',
              colors: Color(0xff1a73e8),
            ),

            Subject(
              iconData: OMIcons.forum,
              title: 'Chinese',
              msg: 'Score 25 more to become an expert!',
              count: '475',
              colors: Color(0xff8024cd),
            ),
            Subject(
              iconData: OMIcons.forum,
              title: 'Analytical',
              msg: 'Good improvement!',
              count: '123 in 4 days',
              colors: Color(0xff8024cd),
            ),

            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
              child: Text(
                'ACTIVE FRIENDS',
                style: TextStyle(
                    fontSize: 15,
                    fontFamily: 'GoogleMedium',
                    color: Colors.black54),
              ),
            ),
            activeFriend(
              sender: "Another Name",
              title: "Just an Exam",
              time: "3 seconds ago",
              studied: "Bangla",
            ),
            activeFriend(
              sender: "Difficult Guy",
              title: "An Exam",
              time: "18 minutes ago",
              studied: "Analytical",
            )
          ],
        ),
      ),

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    将您的Column 包裹在SingleChildScrollView 中,它只需要一个孩子。

    SingleChildScrollView (
       child: Column( ...
    

    【讨论】:

    • 非常感谢。这工作得很好,因为现在只有 1 个孩子。它以某种方式跳过了我。工作解决方案:child: SingleChildScrollView( child: Column(
    猜你喜欢
    • 2020-03-11
    • 2022-11-14
    • 2022-11-04
    • 2019-02-02
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 2020-11-05
    相关资源
    最近更新 更多