I have a layout which is using RefreshIndicator. It's child is CustomScrollView. However when onRefresh handler is called it throws an exception
[ERROR:../../lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (21060): NoSuchMethodError: The method 'call' was called on null.
E/flutter (21060): Receiver: null
E/flutter (21060): Tried calling: call()
E/flutter (21060): #0 Object._noSuchMethod (dart:core-patch/object_patch.dart:43)
E/flutter (21060): #1 Object.noSuchMethod (dart:core-patch/object_patch.dart:47)
E/flutter (21060): #2 new Future.sync (dart:async/future.dart:222)
E/flutter (21060): #3 MyHomePageState.handleRefresh (file:///home/swav/Git/flutter/status-app/lib/state/state.dart:49)
E/flutter (21060): #4 RefreshIndicatorState._show.<anonymous closure> (package:flutter/src/material/refresh_indicator.dart:319)
E/flutter (21060): #5 _RootZone.runUnary (dart:async/zone.dart:1371)
E/flutter (21060): #6 _FutureListener.handleValue (dart:async/future_impl.dart:129)
E/flutter (21060): #7 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636)
E/flutter (21060): #8 _Future._propagateToListeners (dart:async/future_impl.dart:665)
E/flutter (21060): #9 _Future._completeWithValue (dart:async/future_impl.dart:478)
E/flutter (21060): #10 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:510)
E/flutter (21060): #11 _microtaskLoop (dart:async/schedule_microtask.dart:41)
E/flutter (21060): #12 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
Interesting part is that onRefresh completes successfully.
Also when immediate child of RefreshIndicator was a Flex it wasn't complaining.
It's hard to debug your issue because you didn't provide your code, but from the stack trace I can see that in your handleRefresh
method, on line 49 of state.dart, you are calling new Future.sync(null)
, which is trying to invoke null
as a function.
Try using new Future.value(null)
instead when you need a completed Future
with value null
. But RefreshIndicator
doesn't do much when the returned Future completes immediately. You might want to look at this example for inspiration on how to use RefreshIndicator
.
It probably wasn't complaining when the child was a Flex
because a Flex
doesn't scroll.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.