Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError after update to 0.5.0 #71

Closed
PabloPL opened this issue May 11, 2019 · 10 comments · Fixed by #72
Closed

NoSuchMethodError after update to 0.5.0 #71

PabloPL opened this issue May 11, 2019 · 10 comments · Fixed by #72

Comments

@PabloPL
Copy link
Contributor

PabloPL commented May 11, 2019

I'm getting following error after update to 0.5.0 version

I/flutter (21118): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (21118): The following NoSuchMethodError was thrown building Slidable(dirty, dependencies:
I/flutter (21118): [_ScrollableScope], state: SlidableState#1c8cb(tickers: tracking 1 ticker)):
I/flutter (21118): The method '[]' was called on null.
I/flutter (21118): Receiver: null
I/flutter (21118): Tried calling: [](Instance of 'SlideActionType')
I/flutter (21118):
I/flutter (21118): When the exception was thrown, this was the stack:
I/flutter (21118): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
I/flutter (21118): #1 SlidableState._dismissThreshold
package:flutter_slidable/…/widgets/slidable.dart:562
I/flutter (21118): #2 SlidableState.build
package:flutter_slidable/…/widgets/slidable.dart:897
I/flutter (21118): #3 StatefulElement.build
package:flutter/…/widgets/framework.dart:3825
I/flutter (21118): #4 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3739

widget.dismissal is null in _dismissThreshold

Adding some dummy check for null value in dismissal solves error (no idea why ?? operator is not working when ?. returns null...)

@tegab
Copy link

tegab commented May 11, 2019

can you show code on how you solved it.. thnx

@PabloPL
Copy link
Contributor Author

PabloPL commented May 12, 2019

In slidable.dart (in flutter_slidable lib) replace

double get _dismissThreshold =>
    widget.dismissal?.dismissThresholds[actionType] ?? _kDismissThreshold;

With something like this

double get _dismissThreshold {
    if (widget.dismissal == null) return _kDismissThreshold;
    else return widget.dismissal.dismissThresholds[actionType] ?? _kDismissThreshold;
  }

For me it's working fine

@jaumard
Copy link

jaumard commented May 13, 2019

I can confirm the problem (and the solution ^^) would be nice to have this patch and deploy @letsar :)

@jeffaknine
Copy link

First time trying the package and I'm running into this issue as well. @PabloPL maybe you could send a PR to get this fixed ?

@PabloPL
Copy link
Contributor Author

PabloPL commented May 14, 2019

PR created.

@Nothing-Works
Copy link

have the same problem, hopefully, the PR can be merged ASAP.....

@hiroshihorie
Copy link

Please fix ASAP!

@ghost
Copy link

ghost commented May 16, 2019

Until we have this PR merged, I am using a workaround, set dismissal to the following:

dismissal: SlidableDismissal(
     child: SlidableDrawerDismissal(),
     onWillDismiss: (actionType) {
         return false;
     },
),

this is enforcing to have a dismissal property by always is canceling the dismissal actions

@JeffersonCarvalh0
Copy link

Thanks, @eponcedeleon. Your solution worked here, but I had to add a key property to theSlidable object in order for it to work

@letsar
Copy link
Owner

letsar commented May 24, 2019

Fixed in 0.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants