如何使用Always crollableScroll Physics在Flutter中滚动`child:Column`

问题描述 投票:0回答:1

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

下面是我想要实现这一目标的其中一个页面的代码 - 但请注意我面临着关于滚动功能的复杂性。我尝试了ScrollableSingleChildScrollView,两者都给出了“太多位置参数”的错误。根据我的理解,这个问题是我使用一个列来实现这个,这不是正确的方式。

任何关于整个问题的帮助或指示都将非常感激。

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个回答
0
投票

把你的Column包裹在SingleChildScrollView里面,它只需要一个孩子。

SingleChildScrollView (
   child: Column( ...
© www.soinside.com 2019 - 2024. All rights reserved.