简体   繁体   English

Flutter 页面不可滚动:当多个小部件时如何滚动?

[英]Flutter page is not scrollable: How to scroll when more than one widget?

I am trying to make my page scrollable but I didn't manage it.我试图让我的页面可滚动,但我没有管理它。 What I tried so far is to use SingeChildScrollView , ListView and ScrollView ... Everytime I use one of these an error occurs.到目前为止我尝试过的是使用SingeChildScrollViewListViewScrollView ......每次我使用其中一个时都会发生错误。 How can I manage this?我该如何管理? Is there any alternative to use those three options?有没有其他方法可以使用这三个选项? I am new to flutter and what I googled so far didn't work because I could only find solutions with one of these three scrolling options.我是 flutter 的新手,到目前为止我在谷歌上搜索的内容没有用,因为我只能找到这三个滚动选项之一的解决方案。 Thank you!谢谢! This is my code:这是我的代码:


class LadevorgangScreen extends StatefulWidget {
  @override
  _LadevorgangScreen createState() => _LadevorgangScreen();
}

@override
class _LadevorgangScreen extends State<LadevorgangScreen> {
//class LadevorgangScreen extends StatelessWidget {

  PageController pageController = PageController(initialPage: 0);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Ladevorgang'),
        flexibleSpace: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
                colors: [Color(0xffFBD23E), Color(0xffF6BE03)],
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter),
          ),
        ),
      ),
      body: Container(
        decoration: BoxDecoration(
          gradient: LinearGradient(
              colors: [Color(0xffFEFDFD), Color(0xffBDBDB2)],
              begin: Alignment.topLeft,
              end: Alignment.bottomRight),
        ),
        child: Column(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.fromLTRB(10, 15, 10, 45),
              child: FlatButton(
                onPressed: () {},
                color: Colors.blue,
                highlightColor: Colors.transparent,
                splashColor: Colors.transparent,
                child: RichText(
                  textAlign: TextAlign.center,
                  text: TextSpan(
                    text: 'FAQs:\n',
                    style: TextStyle(
                      fontFamily: 'Avenir',
                      fontSize: 22.0,
                      fontWeight: FontWeight.w900,
                      decoration: TextDecoration.underline,
                      color: Color(0xff232323),
                    ),
                    children: [
                      TextSpan(
                        text: 'Ladevorgang des Elektroautos',
                        style: TextStyle(
                            fontFamily: 'Avenir',
                            fontSize: 20.0,
                            fontWeight: FontWeight.w500,
                            decoration: TextDecoration.none,
                            color: Color(0xff232323)),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            Flexible(
              child: Text(
                'Zu Hause laden',
                style: TextStyle(
                    fontSize: 18.5,
                    fontFamily: 'Avenir',
                    fontWeight: FontWeight.w700),
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
              child: Column(
                children: [
                  Row(
                    children: [
                      Padding(
                        padding: EdgeInsets.fromLTRB(0, 12, 7, 12),
                        child: Icon(
                          Icons.circle_outlined,
                          size: 15.0,
                          color: Color(0xffF6BE03),
                        ),
                      ),
                      Flexible(
                        child: Text(
                          "Wie lade ich zu Hause?",
                          style:
                              TextStyle(fontSize: 17.0, fontFamily: 'Avenir'),
                        ),
                      ),
                    ],
                  ),
                  Row(
                    children: [
                      Padding(
                        padding: EdgeInsets.fromLTRB(0, 12, 7, 12),
                        child: Icon(
                          Icons.circle_outlined,
                          size: 15.0,
                          color: Color(0xffF6BE03),
                        ),
                      ),
                      Flexible(
                        child: Text(
                            "Benötige ich überhaupt eine Lademöglichkeit zu Hause?",
                            style: TextStyle(
                                fontSize: 17.0, fontFamily: 'Avenir')),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

JUST WRAP your main widget OF BODY in SingleChildScrollView widget只需将您的主要 BODY 小部件包裹在 SingleChildScrollView 小部件中

   body: SingleChildScrollView(
    child: Container(
      decoration: BoxDecoration
       .....
       ..
       .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用网格 Flutter 同时滚动小部件 - How to scroll widget in same time with grid Flutter 如何拥有一个页面多于一个的页面视图控制器,但是在Swift 4中仅使用一个视图控制器? - how to have a page view controller with more than one page But using just one view controller in swift 4? 在 Flutter 中创建可水平和垂直滚动的小部件 - Creating a widget that is both horizontally and vertically scrollable in Flutter 当多个tableViewControllers(没有情节提要)时,如何推送ViewController - How to pushViewController when more than one tableViewControllers (no storyboards) SKLabelNode - 如何在多条线时居中对齐? - SKLabelNode - how to center align when more than one line? 如何在使用多个时使用正确的fetchedResultsController - How to use the correct fetchedResultsController when using more than one 滚动视图滚动时如何检查视图可滚动位置 - How to check view scrollable position when scrollview scroll 即使 contentSize 小于 frame,如何使 UIScrollView 可滚动? - How to make UIScrollView scrollable even when contentSize is smaller than frame? 如何在Flutter中实现可滚动画布? - How to achieve scrollable canvas in Flutter? 如果其内容大小大于屏幕大小,如何滚动UITableView? - How to scroll UITableView if its content size more than screen size?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM