Padding in ListView Flutter

70 Views Asked by At

why I still got error?

import 'package:flutter/material.dart';
import 'package:kosan2_apps/tema.dart';
import 'package:kosan2_apps/widgets/facilities_item.dart';

class DetailPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: whiteColor,
      body: SafeArea(
        bottom: false,
        child: Stack(children: [
          Image.asset(
            'assets/images/cover.png',
            width: MediaQuery.of(context).size.width,
            height: 350,
            fit: BoxFit.cover,
          ),
          ListView(
            Padding(
              padding: EdgeInsets.symmetric(
                horizontal: edge,
                vertical: 30,
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  InkWell(
                    onTap: () {
                      Navigator.pop(context);
                    },
                    child: Image.asset(
                      'assets/images/btn_back.png',
                      width: 40,
                    ),
                  ),
                  Image.asset(
                    'assets/images/btn_wishlist.png',
                    width: 40,
                  ),
                ],
              ),
            ),
            children: [
              SizedBox(
                height: 328,
              ),
              Container(
                width: MediaQuery.of(context).size.width,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.vertical(
                    top: Radius.circular(20),
                  ),
                  color: whiteColor,
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    SizedBox(
                      height: 30,
                    ),
                    //NOTE TITLE
                    Padding(
                      padding: EdgeInsets.symmetric(
                        horizontal: edge,
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                'Danau Toba Village',
                                style: blackTextStyle.copyWith(
                                  fontSize: 22,
                                ),
                              ),
                              SizedBox(
                                height: 2,
                              ),
                              Text.rich(
                                TextSpan(
                                  text: '\$52',
                                  style: purpleTextStyle.copyWith(
                                    fontSize: 16,
                                  ),
                                  children: [
                                    TextSpan(
                                      text: '/ month',
                                      style: greyTextStyle.copyWith(
                                        fontSize: 16,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          Row(
                            children: [
                              Image.asset(
                                'assets/images/icon_star.png',
                                width: 20,
                              ),
                              SizedBox(
                                width: 2,
                              ),
                              Image.asset(
                                'assets/images/icon_star.png',
                                width: 20,
                              ),
                              SizedBox(
                                width: 2,
                              ),
                              Image.asset(
                                'assets/images/icon_star.png',
                                width: 20,
                              ),
                              SizedBox(
                                width: 2,
                              ),
                              Image.asset(
                                'assets/images/icon_star.png',
                                width: 20,
                              ),
                              SizedBox(
                                width: 2,
                              ),
                              Image.asset(
                                'assets/images/icon_star.png',
                                width: 20,
                                color: Color(0xff989BA1),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 30,
                    ),
                    //NOTE MAIN FACILITIES
                    Padding(
                      padding: EdgeInsets.only(
                        left: edge,
                      ),
                      child: Text(
                        'Main Facilities',
                        style: regularTextStyle.copyWith(
                          fontSize: 16,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 12,
                    ),
                    Padding(
                      padding: EdgeInsets.symmetric(
                        horizontal: edge,
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          FacilitiesItem(
                            name: 'Kitchen',
                            imgUrl: 'assets/images/icon_kitchen.png',
                            totalItem: 2,
                          ),
                          FacilitiesItem(
                            name: 'Bedroom',
                            imgUrl: 'assets/images/icon_bedroom.png',
                            totalItem: 3,
                          ),
                          FacilitiesItem(
                            name: 'Big Cupboard',
                            imgUrl: 'assets/images/icon_cupboard.png',
                            totalItem: 4,
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 30,
                    ),
                    //NOTE PHOTOS
                    Padding(
                      padding: EdgeInsets.only(left: edge),
                      child: Text(
                        'Photos',
                        style: regularTextStyle.copyWith(
                          fontSize: 16,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 12,
                    ),
                    Container(
                      height: 88,
                      child: ListView(
                        scrollDirection: Axis.horizontal,
                        children: [
                          SizedBox(
                            width: 24,
                          ),
                          Image.asset(
                            'assets/images/photo1.png',
                            width: 110,
                            height: 88,
                            fit: BoxFit.cover,
                          ),
                          SizedBox(
                            width: 18,
                          ),
                          Image.asset(
                            'assets/images/photo2.png',
                            width: 110,
                            height: 88,
                            fit: BoxFit.cover,
                          ),
                          SizedBox(
                            width: 18,
                          ),
                          Image.asset(
                            'assets/images/photo3.png',
                            width: 110,
                            height: 88,
                            fit: BoxFit.cover,
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 30,
                      //NOTE LOCATION
                    ),
                    Padding(
                      padding: EdgeInsets.only(left: edge),
                      child: Text(
                        'Location',
                        style: regularTextStyle.copyWith(
                          fontSize: 16,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 6,
                    ),
                    Padding(
                      padding: EdgeInsets.symmetric(
                        horizontal: edge,
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            'Jln Seto Lrg.Sipirok No.23\nMedan',
                            style: greyTextStyle,
                          ),
                          Image.asset(
                            'assets/images/btn_location.png',
                            width: 40,
                          )
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 40,
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(
                        horizontal: edge,
                      ),
                      height: 50,
                      width: MediaQuery.of(context).size.width - (2 * edge),
                      child: ElevatedButton(
                        onPressed: () {},
                        child: Text(
                          'Book Now',
                          style: TextStyle(
                            color: whiteColor,
                            fontSize: 18,
                          ),
                        ),
                        style: ButtonStyle(
                          shape: MaterialStateProperty.all(
                            RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(17),
                            ),
                          ),
                          backgroundColor: MaterialStateProperty.resolveWith(
                            (states) {
                              return purpleColor;
                            },
                          ),
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 40,
                    ),
                  ],
                ),
              )
            ],
          )
        ]),
      ),
    );
  }
}

Can anyone fix it?

1

There are 1 best solutions below

0
Md. Yeasin Sheikh On

You need to place Padding inside the children

class DetailPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: whiteColor,
      body: SafeArea(
        bottom: false,
        child: Stack(children: [
          Image.asset(
            'assets/images/cover.png',
            width: MediaQuery.of(context).size.width,
            height: 350,
            fit: BoxFit.cover,
          ),
          ListView(
            children: [
              Padding(  //here
                padding: EdgeInsets.symmetric(
                  horizontal: edge,
                  vertical: 30,
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(
                      onTap: () {
                        Navigator.pop(context);
                      },
                      child: Image.asset(
                        'assets/images/btn_back.png',
                        width: 40,
                      ),
                    ),
                    Image.asset(
                      'assets/images/btn_wishlist.png',
                      width: 40,
                    ),
                  ],
                ),
              ),
              SizedBox(
                height: 328,
              ),
              Container(
                width: MediaQuery.of(context).size.width,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.vertical(
                    top: Radius.circular(20),
                  ),
                  // color: whiteColor,
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    SizedBox(
                      height: 30,
                    ),
                    //NOTE TITLE
                    Padding(
                      padding: EdgeInsets.symmetric(
                        horizontal: edge,
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                'Danau Toba Village',
                                // style: blackTextStyle.copyWith(
                                //   fontSize: 22,
                                // ),
                              ),
                              SizedBox(
                                height: 2,
                              ),
                              Text.rich(
                                TextSpan(
                                  text: '\$52',
                                  // style: purpleTextStyle.copyWith(
                                  //   fontSize: 16,
                                  // ),
                                  children: [
                                    TextSpan(
                                      text: '/ month',
                                      // style: greyTextStyle.copyWith(
                                      //   fontSize: 16,
                                      // ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          Row(
                            children: [
                              // Image.asset(
                              //   'assets/images/icon_star.png',
                              //   width: 20,
                              // ),
                              // SizedBox(
                              //   width: 2,
                              // ),
                              // Image.asset(
                              //   'assets/images/icon_star.png',
                              //   width: 20,
                              // ),
                              // SizedBox(
                              //   width: 2,
                              // ),
                              // Image.asset(
                              //   'assets/images/icon_star.png',
                              //   width: 20,
                              // ),
                              // SizedBox(
                              //   width: 2,
                              // ),
                              // Image.asset(
                              //   'assets/images/icon_star.png',
                              //   width: 20,
                              // ),
                              // SizedBox(
                              //   width: 2,
                              // ),
                              // Image.asset(
                              //   'assets/images/icon_star.png',
                              //   width: 20,
                              //   color: Color(0xff989BA1),
                              // ),
                            ],
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 30,
                    ),
                    //NOTE MAIN FACILITIES
                    Padding(
                      padding: EdgeInsets.only(
                        left: edge,
                      ),
                      child: Text(
                        'Main Facilities',
                        // style: regularTextStyle.copyWith(
                        //   fontSize: 16,
                        // ),
                      ),
                    ),
                    SizedBox(
                      height: 12,
                    ),
                    Padding(
                      padding: EdgeInsets.symmetric(
                        horizontal: edge,
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          // FacilitiesItem(
                          //   name: 'Kitchen',
                          //   imgUrl: 'assets/images/icon_kitchen.png',
                          //   totalItem: 2,
                          // ),
                          // FacilitiesItem(
                          //   name: 'Bedroom',
                          //   imgUrl: 'assets/images/icon_bedroom.png',
                          //   totalItem: 3,
                          // ),
                          // FacilitiesItem(
                          //   name: 'Big Cupboard',
                          //   imgUrl: 'assets/images/icon_cupboard.png',
                          //   totalItem: 4,
                          // ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 30,
                    ),
                    //NOTE PHOTOS
                    Padding(
                      padding: EdgeInsets.only(left: edge),
                      child: Text(
                        'Photos',
                        style: regularTextStyle.copyWith(
                          fontSize: 16,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 12,
                    ),
                    Container(
                      height: 88,
                      child: ListView(
                        scrollDirection: Axis.horizontal,
                        children: [
                          SizedBox(
                            width: 24,
                          ),
                          Image.asset(
                            'assets/images/photo1.png',
                            width: 110,
                            height: 88,
                            fit: BoxFit.cover,
                          ),
                          SizedBox(
                            width: 18,
                          ),
                          Image.asset(
                            'assets/images/photo2.png',
                            width: 110,
                            height: 88,
                            fit: BoxFit.cover,
                          ),
                          SizedBox(
                            width: 18,
                          ),
                          Image.asset(
                            'assets/images/photo3.png',
                            width: 110,
                            height: 88,
                            fit: BoxFit.cover,
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 30,
                      //NOTE LOCATION
                    ),
                    Padding(
                      padding: EdgeInsets.only(left: 0),
                      child: Text(
                        'Location',
                        // style: regularTextStyle.copyWith(
                        //   fontSize: 16,
                        // ),
                      ),
                    ),
                    SizedBox(
                      height: 6,
                    ),
                    Padding(
                      padding: EdgeInsets.symmetric(
                          // horizontal: edge,
                          ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            'Jln Seto Lrg.Sipirok No.23\nMedan',
                            // style: greyTextStyle,
                          ),
                          Image.asset(
                            'assets/images/btn_location.png',
                            width: 40,
                          )
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 40,
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(
                          // horizontal: edge,
                          ),
                      height: 50,
                      width: MediaQuery.of(context).size.width - (2 * edge),
                      child: ElevatedButton(
                        onPressed: () {},
                        child: Text(
                          'Book Now',
                          style: TextStyle(
                            // color: whiteColor,
                            fontSize: 18,
                          ),
                        ),
                        style: ButtonStyle(
                          shape: MaterialStateProperty.all(
                            RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(17),
                            ),
                          ),
                          // backgroundColor: MaterialStateProperty.resolveWith(
                          //   (states) {
                          //     return purpleColor;
                          //   },
                          // ),
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 40,
                    ),
                  ],
                ),
              )
            ],
          )
        ]),
      ),
    );
  }
}

More about ListView