Code Monkey home page Code Monkey logo

fading_edge_scrollview's Introduction

fading_edge_scrollview

Package providing FadingEdgeScrollView which allows you to build scrollable views with fading edges

Usage

Create FadingEdgeScrollView by calling one of constructors depending on your scroll view class. Unfortunately scrollable view don't share same interface so there are separate constructors for:

  • ScrollView (most scrollable views inherit from this class) FadingEdgeScrollView.fromScrollView
  • SingleChildScrollView FadingEdgeScrollView.fromSingleChildScrollView
  • PageView FadingEdgeScrollView.fromPageView
  • AnimatedList FadingEdgeScrollView.fromAnimatedList
  • ListWheelScrollView FadingEdgeScrollView.fromListWheelScrollView

View passed as child MUST have controller set.

See documentation and example folder for more information

Breaking change in version 4.0.0

Field shouldDisposeScrollController was removed. I was not realizing how widgets should work when I added it. If you were using it - move scrollController creation and disposal to some StatefulWidget.

Demo

Click to see on Youtube:
ListView with images demo ListView demo PageView demo SingleChildScrollView demo

fading_edge_scrollview's People

Contributors

cooldude53 avatar davidmartos96 avatar felixwoestmann avatar georgeherby avatar mponkin avatar polina-c avatar ruslic19 avatar scris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fading_edge_scrollview's Issues

Null safety

Could you please support null safety, so this library can be used in null safe project? Thank you.

Shadow color

A feature to specify a custom shadow color would be nice.

Support for RTL and LTR at the same time

I have a multi language app
The package works fine with LTR using FadingEdgeScrollView.fromScrollView
But its not functional with RTL
I think AlignmentDirectional should do the trick
Thank you for your efforts

Fatal Null Check

I am using fading_edge_scrollview 3.0.0 on Flutter 2.10.3, and when I try to run my app I get these warnings:

C:/..../flutter/.pub-cache/hosted/pub.dartlang.org/fading_edge_scrollview-3.0.0/lib/src/fading_edge_scrollview.dart:196:10: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/..../flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
Try calling using ?. instead.
      it.addPostFrameCallback(_postFrameCallback);
         ^^^^^^^^^^^^^^^^^^^^

/C:/..../flutter/.pub-cache/hosted/pub.dartlang.org/fading_edge_scrollview-3.0.0/lib/src/fading_edge_scrollview.dart:197:10: Error: Method 'addObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/..../flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
Try calling using ?. instead.
      it.addObserver(this);

/C:/..../flutter/.pub-cache/hosted/pub.dartlang.org/fading_edge_scrollview-3.0.0/lib/src/fading_edge_scrollview.dart:220:29: Error: Method 'removeObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/..../flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
Try calling using ?. instead.
    WidgetsBinding.instance.removeObserver(this);

I did all the suggested changes in fading_edge_scrollview.dart and now it works.
Can you fix this in the repo?

How to make Fading effect appear automatically when Listview is scrollable?

I am using a SingleChildScrollView and inside is an AnimatedList that can automatically scroll down to the last item. I found that the effect only appeared when I was using my hand and scrolling. I want to know is there a way to make the Fading effect appear automatically when the Listview is scrollable?

ScrollController attached to multiple scroll views

Triggering Way:

  1. I made a FadingEdgeScrollView.fromSingleChildScrollView with a ScrollController() and then nested it in a ListView.
  2. I placed a PieMenu(https://pub.dev/packages/pie_menu, which has a LongPress gesture bounden) as a parent of the FadingEdgeScrollView.
  3. When I did the long press, I was getting the ScrollController attached to multiple scroll views error.

Although involved, I think this problem is not connected with PieMenu, it's just one of the ways of triggering this error (triggerable by other done-by-user operations, too). The reason of the error is most probably affiliated with getting multiple positions.

Involved Version:

3.0.0, upon Flutter 3.16.

Full Error Output:

The following assertion was thrown during a scheduler callback:
ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 158 pos 12: '_positions.length == 1'

When the exception was thrown, this was the stack: 
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:158:12)
#3      _FadingEdgeScrollViewState._controllerIsReady (package:fading_edge_scrollview/src/fading_edge_scrollview.dart:202:45)
#4      _FadingEdgeScrollViewState._postFrameCallback (package:fading_edge_scrollview/src/fading_edge_scrollview.dart:210:9)
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1264:9)
#7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
#8      _invoke (dart:ui/hooks.dart:312:13)
#9      PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
#10     _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _AssertionError)

Solving Strategy:

I tested and found it solvable by https://stackoverflow.com/a/70672454/15439845. I'll make a pull request later.

Non-fatal null check operator issue

Using fading_edge_scrollview 2.0.0, and I found this issue being reported quite often in our crashlytics console, which seems to point to an issue with the fact _isScrolledToEnd can be null based off the line it points to.
`

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown Instance of 'ErrorDescription'.
at ScrollPosition.maxScrollExtent(ScrollPosition.java:140)
at _FadingEdgeScrollViewState._postFrameCallback(_FadingEdgeScrollViewState.java:206)
at SchedulerBinding._invokeFrameCallback(SchedulerBinding.java:1144)
at SchedulerBinding.handleDrawFrame(SchedulerBinding.java:1090)
at SchedulerBinding._handleDrawFrame(SchedulerBinding.java:998)

Why have multiple constructors when they all call the same internal constructor with the same arguments

I found out that you are creating constructors for no reason when you don't do anything special for each constructor :
here check these constructors they have the same implementation but with different constructor arguments :

  /// Constructor for creating [FadingEdgeScrollView] with [PageView] as child
  /// child must have [PageView.controller] set
  factory FadingEdgeScrollView.fromPageView({
    Key key,
    @required PageView child,
    double gradientFractionOnStart = 0.1,
    double gradientFractionOnEnd = 0.1,
    bool shouldDisposeScrollController = false,
  }) {
    assert(child.controller != null, "Child must have controller set");

    return FadingEdgeScrollView._internal(
      key: key,
      child: child,
      scrollController: child.controller,
      scrollDirection: child.scrollDirection,
      reverse: child.reverse,
      gradientFractionOnStart: gradientFractionOnStart,
      gradientFractionOnEnd: gradientFractionOnEnd,
      shouldDisposeScrollController: shouldDisposeScrollController,
    );
  }

  /// Constructor for creating [FadingEdgeScrollView] with [AnimatedList] as child
  /// child must have [AnimatedList.controller] set
  factory FadingEdgeScrollView.fromAnimatedList({
    Key key,
    @required AnimatedList child,
    double gradientFractionOnStart = 0.1,
    double gradientFractionOnEnd = 0.1,
    bool shouldDisposeScrollController = false,
  }) {
    assert(child.controller != null, "Child must have controller set");

    return FadingEdgeScrollView._internal(
      key: key,
      child: child,
      scrollController: child.controller,
      scrollDirection: child.scrollDirection,
      reverse: child.reverse,
      gradientFractionOnStart: gradientFractionOnStart,
      gradientFractionOnEnd: gradientFractionOnEnd,
      shouldDisposeScrollController: shouldDisposeScrollController,
    );
  }

why is that ?

Problem on flutter 3.10

Hello with flutter 3.10 I have pixelated children:

Before:
IMG_5052

Flutter 3.10:
IMG_5053

Any ideas to fix this ? Thx 😇

"The getter 'position' was called on null" throws when using a FadingEdgeScrollView inside the TabBarView

A null pointer exception is thrown when using the FadingEdgeScrollView inside the TabBarView.

Steps to reproduce:

  1. Clone this repo with a minimum code which reproduces the problem: shemhazai/flutter_fading_edge_scrollview
  2. Navigate through pages by clicking on the TabBar tabs (must not be adjacent tabs).
  3. The exception is thrown (as posted below).

I/flutter ( 6149): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY >╞═════════════════════════════════════════════════════════
I/flutter ( 6149): The following NoSuchMethodError was thrown during a scheduler callback:
I/flutter ( 6149): The getter 'position' was called on null.
I/flutter ( 6149): Receiver: null
I/flutter ( 6149): Tried calling: position
I/flutter ( 6149):
I/flutter ( 6149): When the exception was thrown, this was the stack:
I/flutter ( 6149): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
I/flutter ( 6149): #1 _FadingEdgeScrollViewState.initState. (package:fading_edge_scrollview/src/fading_edge_scrollview.dart:168:23)
I/flutter ( 6149): #2 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
I/flutter ( 6149): #3 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1060:9)
I/flutter ( 6149): #4 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:968:5)
I/flutter ( 6149): #8 _invoke (dart:ui/hooks.dart:261:10)
I/flutter ( 6149): #9 _drawFrame (dart:ui/hooks.dart:219:3)
I/flutter ( 6149): (elided 3 frames from dart:async)

I did not experience this exception when I was using the FadingEdgeScrollView without the TabBarView - so most likely this is an important factor to consider.

Hide fade if content too small to be scrollable

It may happen that content inside the scollable is too small.
In that case Flutter handle it quite well : Ripple effects are disabled along with scrolling.
But the fade stays.
How to hide the fade in that case ?

Flutter 3.0.0 is detecting issue with the library

../../../Documents/flutter/.pub-cache/hosted/pub.dartlang.org/fading_edge_scrollview-2.0.1/lib/src/fading_edge_scrollview.dart:220:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.

  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.removeObserver(this);

Don't dispose my ScrollController for me

This plugin calls .dispose() on the ScrollController argument it receives.

This means the obvious usage pattern is now wrong:

class _MyWidgetState extends State<MyWidget> {
  ScrollController _myController;

  @override
  void initState() {
    super.initState();
    _myController = ScrollController();
  }

  @override
  void dispose() {
    // Wrong, because this plugin wants me *not* to dispose my own controller!
    _myController.dispose();
    super.dispose();
  }

  @override
  Widget build() {
    return FadingEdgeScrollView.fromScrollView(child: ... _myController ...);
  }
}

This is surprising: If I'm supposed to create the controller and pass it in, it should also be my job to dispose it. This is the way it works everywhere else in Flutter.

So, I think you should not dispose the controller and let the user control its lifetime instead. This user ran into the same problem and would probably agree.

Thank you!

error build for flutter3.22.0

Could not build the precompiled application for the device.
Error (Xcode): ../.pub-cache/hosted/pub.dev/fading_edge_scrollview-3.0.0/lib/src/fading_edge_scrollview.dart:116:31: Error: The argument type 'PageController?' can't be assigned to the parameter type 'ScrollController' because 'PageController?' is nullable and 'ScrollController' isn't.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.