【问题标题】:flutter scrolling does not work: ListView and SingleChildScrollView颤动滚动不起作用:ListView 和 SingleChildScrollView
【发布时间】:2021-03-15 23:27:12
【问题描述】:

我一直在阅读使我的屏幕滚动失败的解决方案。下面是我的代码: '''

class WelcomeScreen extends StatefulWidget {
  static const String id = 'welcome_screen';

  @override
  _WelcomeScreenState createState() => _WelcomeScreenState();
}

class _WelcomeScreenState extends State<WelcomeScreen>
    with SingleTickerProviderStateMixin {
  AnimationController controller;
  Animation animation;

  @override
  void initState() {
    super.initState();

    controller =
        AnimationController(duration: Duration(seconds: 1), vsync: this);
    animation = ColorTween(begin: Colors.blueGrey, end: Colors.white)
        .animate(controller);
    controller.forward();
    controller.addListener(() {
      setState(() {});
    });
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: animation.value,
      body: Padding(
        padding: EdgeInsets.symmetric(horizontal: 24.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Row(
              children: <Widget>[
                Hero(
                  tag: 'logo',
                  child: Container(
                    child: Image.asset('images/logo.png'),
                    height: 60.0,
                  ),
                ),
                TypewriterAnimatedTextKit(
                  text: ['Tonnah'],
                  textStyle: TextStyle(
                    fontSize: 45.0,
                    fontWeight: FontWeight.w900,
                  ),
                ),
              ],
            ),
            SizedBox(
              height: 48.0,
            ),
            RoundedButton(
              title: 'Log In',
              colour: Colors.lightBlueAccent,
              onPressed: () {
                Navigator.pushNamed(context, LoginScreen.id);
              },
            ),
            RoundedButton(
              title: 'Register',
              colour: Colors.blueAccent,
              onPressed: () {
                Navigator.pushNamed(context, RegistrationScreen.id);
              },
            ),
          ],
        ),
      ),
    );
  }
}

''' 我试过 ListView 和 SingleChildScrollView 但没有任何效果。这是一个注册页面,我将使用它来捕获有关用户的信息。我不知道这是否是最好的方法,或者我是否应该让用户在使用电子邮件和密码注册后填写个人资料。

我是 Flutter 和移动应用开发的新手,请帮忙?

TIA

【问题讨论】:

    标签: flutter scroll


    【解决方案1】:

    只需使用 SingleChildScrollView() 包装您的列

    【讨论】:

    • 感谢您的评论。我已经尝试过了,但它没有用。我已经重新设计了该页面,但在另一个页面上需要它,所以我会再试一次。
    猜你喜欢
    • 2021-10-28
    • 2021-08-11
    • 1970-01-01
    • 1970-01-01
    • 2020-02-21
    • 1970-01-01
    • 1970-01-01
    • 2020-05-15
    • 1970-01-01
    相关资源
    最近更新 更多