1

So as you can in the video attached, there is a problem in scrolling. It should be like an infinite scroll view (like on facebook's app news feed)

The problem is there seems to be a "nested" scroll within the parent ListView. How can I fix this? Please assist

VIDEO HERE (I don't know how to attach a video here so I put it on youtube)

my homepage code is this where the More Offers section should just be generating datas from the firebase backend continously like on facebook's news feed:

  @override
  Widget build(BuildContext context) {


    width = MediaQuery.of(context).size.width;

    return SafeArea(
        child: Scaffold(
          backgroundColor: Color(0xFF0d192a),
        appBar: CustomAppBar(height: 60),
        // appBar: CustomAppBar(height: 70),
        drawer: DrawerNiVlad(),

        body: ListView(
          //vlad
          children: <Widget>[

           // some widgets here

          ArlTitleText('More Offers'),
          MoreOffers(), <= The widget that has a "nested scroll"
          sb5,

the MoreOffers widget code

Widget build(BuildContext context) {
    return StreamBuilder(
        initialData: List<DiscountEntity>(),
        stream: _moreOffersBloc.listDiscounts3Flux,
        builder: (BuildContext context, AsyncSnapshot snapshot) {
          if (!snapshot.hasData) return Container(height: 1, width: 1);
          return ListView.builder(
            shrinkWrap: true,
            padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0),
            scrollDirection: Axis.vertical,
            itemCount: snapshot.data.length,
            itemBuilder: (BuildContext context, int index) {
              DiscountEntity discount =
                  snapshot.data[index] as DiscountEntity;
              return Container(
                decoration: BoxDecoration(
                    // border: Border(bottom: BorderSide()),
                    ),
                child: Card(
                    color: Color(0xFF0d192a),
                    child: Padding(
                      padding: const EdgeInsets.symmetric(
                          horizontal: 5.0, vertical: 5.0),
                      child: Stack(
                        children: <Widget>[
                          InkWell(
                            onTap: () {
                              print('123123');
                              Navigator.push(
                                context,
                                MaterialPageRoute(
                                  builder: (_) => DetailsDiscountPage(
                                    discount: discount,
                                  ),
                                ),
                              );
                            }, // button pressed
                            child: Container(
                              width: 100.0,
                              height: 100.0,
                              decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(5.0)),
                                color: Colors.black,
                              ),
                              child: Image.network(
                                // 'asdkmnajhkalskca',
                                discount.imageUrl.Url,
                                fit: BoxFit.cover,
                                loadingBuilder: (BuildContext context,
                                    Widget child,
                                    ImageChunkEvent loadingProgress) {
                                  if (loadingProgress == null) return child;
                                  return Center(
                                    child: CircularProgressIndicator(
                                      backgroundColor: Colors.white,
                                      valueColor:
                                          AlwaysStoppedAnimation<Color>(
                                              goldColor),
                                      value: loadingProgress
                                                  .expectedTotalBytes !=
                                              null
                                          ? loadingProgress
                                                  .cumulativeBytesLoaded /
                                              loadingProgress
                                                  .expectedTotalBytes
                                          : null,
                                    ),
                                  );
                                },
                              ),
                            ),
                          ),
                          Positioned(
                            left: 110,
                            top: 1,
                            child: InkWell(
                              onTap: () {
                                print('asdasdasdas');
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                    builder: (_) => DetailsDiscountPage(
                                      discount: discount,
                                    ),
                                  ),
                                );
                              }, // button pressed
                              child: Container(
                                child: Text(
                                  discount.name,
                                  style: TextStyle(
                                      color: goldColor,
                                      fontSize: 15,
                                      letterSpacing: 1,
                                      fontFamily: 'Lato',
                                      fontWeight: FontWeight.bold),
                                ),
                              ),
                            ),
                          ),
                          Positioned(
                            left: 110,
                            top: 17,
                            child: Container(
                              child: Text(
                                //  discount.type,
                                'category',
                                style: TextStyle(
                                    color: Color(0xff7a7a7a),
                                    fontSize: 15,
                                    letterSpacing: 1,
                                    fontFamily: 'Lato',
                                    fontWeight: FontWeight.normal),
                              ),
                            ),
                          ),
                          Positioned(
                            left: 110,
                            top: 35,
                            child: Container(
                                child: Row(
                              children: <Widget>[
                                Icon(
                                  Icons.calendar_today,
                                  color: Color(0xff7a7a7a),
                                  size: 15,
                                ),
                                Text(
                                  'Jan 1, 2020 - Dec 1, 2020',
                                  style: TextStyle(
                                      color: Color(0xff7a7a7a),
                                      fontSize: 15,
                                      letterSpacing: 1,
                                      fontFamily: 'Lato',
                                      fontWeight: FontWeight.normal),
                                ),
                              ],
                            )),
                          ),
                        ],
                      ),
                    )),
              );
            },
          );
        });
4
  • wrap with singlechildscrollview Commented Jan 30, 2020 at 5:00
  • @Avinash what should I wrap with Singlechild scroll view? Commented Jan 30, 2020 at 5:04
  • your top of widget Commented Jan 30, 2020 at 5:08
  • @Avinash okay Ill try it both on homepage andnon the actual widget Commented Jan 30, 2020 at 5:40

1 Answer 1

6

In your ListView.builder, add a primary property and set its value to false

return ListView.builder(
  primary: false, // add this line 
  shrinkWrap: true,
  ... etc ...
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.