Zeke
Zeke

Reputation: 117

Scroll Function In Flutter Web

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
              )
        ],
      ),
    );
  }
}

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?

Thank you.

Upvotes: 3

Views: 1446

Answers (1)

Ravindra S. Patil
Ravindra S. Patil

Reputation: 14775

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

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

Upvotes: 11

Related Questions