TatsuUkraine / flutter_sticky_infinite_list

Multi directional infinite list with Sticky headers for Flutter applications
BSD 2-Clause "Simplified" License
341 stars 31 forks source link

Can't slide when the list is not high enough #24

Closed w497763094 closed 4 years ago

w497763094 commented 4 years ago

I add BouncingScrollPhysics() ,but Can't slide when the list is not high enough. Example: InfiniteList( /// Scroll controller. Optional controller: ScrollController(),

              /// Render scroll in both directions. `Optional`
              direction: InfiniteListDirection.multi,

              /// Render 100 elements in negative direction. `Optional`
              ///
              /// If it's not provided, scroll will be infinite in negative direction
              ///
              /// Will be ignored if [direction] is forward
              ///
              /// If it's `null`, list will be infinite
              minChildCount: -0,

              /// Render 100 elements in positive direction. `Optional`
              ///
              /// If it's not provided, scroll will be infinite in positive direction
              ///
              /// If it's `null`, list will be infinite
              maxChildCount: 1,
              physics: BouncingScrollPhysics(),
              /// ViewPort anchor value. See [ScrollView] docs for more info
              anchor: 0.0,

              /// Item builder
              builder: (BuildContext context, int index) {
                /// Builder requires [InfiniteList] to be returned
                return InfiniteListItem(
                  /// If header should be build during initial render.
                  ///
                  /// Will be ignored with just [headerBuilder] builder specified
                  initialHeaderBuild: true,

                  /// Header builder with state
                  ///
                  /// Will be invoked each time header changes it's position
                  ///
                  /// If you don't need to rerender header on each
                  /// position change - use [headerBuilder] builder
                  headerStateBuilder: (BuildContext context, StickyState<int> state) {
                    return Container(
                      alignment: Alignment.center,
                      width: double.infinity,
                      height: 50,
                      child: Text("Header $index"),
                      color: Colors.orange.withOpacity(state.position),
                    );
                  },

                  /// This is just example
                  ///
                  /// In you application you should use or
                  /// [headerBuilder] or [headerStateBuilder],
                  /// but not both
                  ///
                  /// If both is specified, this invoker will be ignored
                  headerBuilder: (BuildContext context) {
                    return Container(
                      alignment: Alignment.center,
                      width: double.infinity,
                      height: 50,
                      child: Text("Header $index"),
                      color: Colors.orange,
                    );
                  },

                  /// Content builder
                  contentBuilder: (BuildContext context) {
                    return Container(
                      width: double.infinity,
                      height: 300,
                      child: Text(
                        "Content $index",
                        style: TextStyle(
                          color: Colors.white,
                        ),
                      ),
                      color: Colors.blueAccent,
                    );
                  },

                  /// Min offset after which it
                  /// should stick to the bottom edge
                  /// of container
                  minOffsetProvider: (StickyState<int> state) => 50,

                  /// Header alignment
                  ///
                  /// Currently it supports top left,
                  /// top right, bottom left and bottom right alignments
                  ///
                  /// By default [HeaderAlignment.topLeft]
                  headerAlignment: HeaderAlignment.topLeft,

                );
              }
          )
TatsuUkraine commented 4 years ago

Hello. Do you have any errors in logs? Also what device are you using? So I could test this case more property

TatsuUkraine commented 4 years ago

Also I'm curious, what kind of effect are you trying to achieve? Case here that this plugin uses simple CustomScrollView, so quite possible that flutter works like it works 🤷‍♂️

w497763094 commented 4 years ago

I want to add refresh at the head of the list, and add more at the bottom, but when the list data is low, if the height of the data does not exceed the height of the screen, it cannot respond to the sliding event. I added a rebound effect to the list and it didn't work (BouncingScrollPhysics ())

w497763094 commented 4 years ago

You can run the code and you will find that the list cannot be scrolled. I set physics: BouncingScrollPhysics (), but it has no effect

TatsuUkraine commented 4 years ago

have you tried to do the same but with the regular scrollable widget?

TatsuUkraine commented 4 years ago

I'm asking because it seems that an issue, which you described, is quite similar to this issue https://github.com/flutter/flutter/issues/25566

TatsuUkraine commented 4 years ago

Which means that you can solve it by using AlwaysScrollableScrollPhysics like

physics: AlwaysScrollableScrollPhysics( 
  parent: BouncingScrollPhysics()
),
w497763094 commented 4 years ago

You are right, I tried it and it works, thank you very much

TatsuUkraine commented 4 years ago

I can assume an issue can be closed in that case?)

w497763094 commented 4 years ago

Of course, you can close this issue。 Thanks again!

TatsuUkraine commented 4 years ago

np)