mponkin / fading_edge_scrollview

Flutter library for displaying fading edges on scroll views
BSD 3-Clause "New" or "Revised" License
43 stars 30 forks source link

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

Closed shemhazai closed 4 years ago

shemhazai commented 4 years ago

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.

mponkin commented 4 years ago

Turns out in this situation PostFrameCallback happens after the widget is disposed. So I added check for this. Fix is available in version 1.1.4 Thank you for pointing out this problem and providing such helpful description