如何使用AlwaysScrollableScrollPhysics在Flutter上滚动`child:Column`

时间:2019-02-24 17:49:26

标签: flutter flutter-layout

我的目的是在页面上实现滚动,默认情况下将限制过度滚动。这是由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",
            )
          ],
        ),
      ),

1 个答案:

答案 0 :(得分:0)

Column包裹在SingleChildScrollView内,只需要一个孩子。

SingleChildScrollView (
   child: Column( ...