Flutter Web 中的滚动功能 [英] Scroll Function In Flutter Web

查看:49
本文介绍了Flutter Web 中的滚动功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是 Flutter Web 的新手.我的 flutter web 中有 3 行,第一行是欢迎信息,第二行是产品,最后一行是联系,要查看用户需要在我的 Web 上滚动的行.但是如何在 flutter web 中使用 Scroll 函数来包装我的代码?这是我的代码.

I'm still new to Flutter Web. I have 3 lines in my flutter web, the first line is the welcome message, the second line is a product and the last is contact, to see those lines user needs to do a scroll on my web. But how can I wrap my code using the Scroll function in flutter web? this is my code.

  class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Scaffold(
      body: Column(
        children: [
          Container(
            // Code Line 1
            height: size.height,
            width: size.width,
            decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage("assets/images/container.jpg"),
                  fit: BoxFit.fitWidth),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                CusAppBar(),
                Spacer(),
                Body(),
                Spacer(
                  flex: 1,
                ),
              ],
            ),
          ),
          Container(
              // Code Line 2 Here
              ),
          Container(
              // Code Line 3 Here
              )
        ],
      ),
    );
  }
}

我的背景是react,通常我们只是在容器外使用标签ScrollView,这样用户就可以滚动页面.但是我如何在flutter web上实现它?

My background is react, usually we just use tag ScrollView outside the container so the user can scroll the page. But how I can implement it on flutter web?

谢谢.

推荐答案

尝试在 SingleChildScrollView 中添加您的第一个 Column,如下所示希望对您有所帮助:

Try to add your fist Column inside SingleChildScrollView like below hope it help you:

body: SingleChildScrollView(
   child:Column(
     children:[
      //Declare Your Widgets Here
     ],
   ),
),

这篇关于Flutter Web 中的滚动功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆