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

Unhandled Exception: type 'SliverHitTestResult' is not a subtype of type 'BoxHitTestResult' #49

Closed
KagurazakaHanabi opened this issue May 12, 2019 · 25 comments

Comments

@KagurazakaHanabi
Copy link

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.5.9-pre.188, on Microsoft Windows [Version 10.0.18356.16], locale zh-CN)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.33.1)
[√] Connected device (2 available)

• No issues found!

Logs

E/flutter ( 2748): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'SliverHitTestResult' is not a subtype of type 'BoxHitTestResult'
E/flutter ( 2748): #0      RenderSliverVariableSizeBoxAdaptor.hitTestChildren (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:380:27)
E/flutter ( 2748): #1      RenderSliver.hitTest (package:flutter/src/rendering/sliver.dart:1273:11)
E/flutter ( 2748): #2      SliverHitTestResult.addWithAxisOffset (package:flutter/src/rendering/sliver.dart:850:19)
E/flutter ( 2748): #3      RenderSliverPadding.hitTestChildren (package:flutter/src/rendering/sliver_padding.dart:266:14)
E/flutter ( 2748): #4      RenderSliver.hitTest (package:flutter/src/rendering/sliver.dart:1273:11)
E/flutter ( 2748): #5      RenderViewportBase.hitTestChildren.<anonymous closure> (package:flutter/src/rendering/viewport.dart:585:24)
E/flutter ( 2748): #6      BoxHitTestResult.addWithRawTransform (package:flutter/src/rendering/box.dart:791:19)
E/flutter ( 2748): #7      BoxHitTestResult.addWithPaintTransform (package:flutter/src/rendering/box.dart:722:12)
E/flutter ( 2748): #8      RenderViewportBase.hitTestChildren (package:flutter/src/rendering/viewport.dart:581:33)
E/flutter ( 2748): #9      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #10     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #11     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #12     RenderIgnorePointer.hitTest (package:flutter/src/rendering/proxy_box.dart:2963:37)
E/flutter ( 2748): #13     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #14     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #15     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #16     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:161:19)
E/flutter ( 2748): #17     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #18     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #19     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #20     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:161:19)
E/flutter ( 2748): #21     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #22     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #23     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #24     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #25     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #26     RenderCustomPaint.hitTestChildren (package:flutter/src/rendering/custom_paint.dart:508:18)
E/flutter ( 2748): #27     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #28     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #29     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #30     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #31     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #32     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:114:19)
E/flutter ( 2748): #33     RenderCustomPaint.hitTestChildren (package:flutter/src/rendering/custom_paint.dart:508:18)
E/flutter ( 2748): #34     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2100:11)
E/flutter ( 2748): #35     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.hitTestChildren (packa
@dereklakin
Copy link
Contributor

Same here using StaggeredGridView inside a NestedScrollView when trying to scroll.

@Theunodb
Copy link

Also having this problem.

@jarekb123
Copy link

Also having this issue.

@dereklakin
Copy link
Contributor

It's something to do with the hitTestChildren method in SliverVariableSizeBoxAdapter. If I revert it to just call super.hitTestChildren then scrolling works, but onTap on my child items never fires, so there's more to it than that :)

@dereklakin
Copy link
Contributor

I've fixed it for my scenario, though I'm not sure if it will work for everyone. In sliver_variable_size_box_adaptor.dart change hitTestChildren method to:

  bool hitTestChildren(HitTestResult result,
      {@required double mainAxisPosition, @required double crossAxisPosition}) {
    for (var child in children) {
      if (hitTestBoxChild(BoxHitTestResult.wrap(result), child,
          mainAxisPosition: mainAxisPosition,
          crossAxisPosition: crossAxisPosition)) return true;
    }
    return false;
  }

The important bit is the change to call BoxHitTestResult.wrap(result) in the call to hitTestBoxChild instead of just passing result.

@korbacsk
Copy link

Same problem.

@jitenders859
Copy link

same problem

@vishaakm
Copy link

I've fixed it for my scenario, though I'm not sure if it will work for everyone. In sliver_variable_size_box_adaptor.dart change hitTestChildren method to:

  bool hitTestChildren(HitTestResult result,
      {@required double mainAxisPosition, @required double crossAxisPosition}) {
    for (var child in children) {
      if (hitTestBoxChild(BoxHitTestResult.wrap(result), child,
          mainAxisPosition: mainAxisPosition,
          crossAxisPosition: crossAxisPosition)) return true;
    }
    return false;
  }

The important bit is the change to call BoxHitTestResult.wrap(result) in the call to hitTestBoxChild instead of just passing result.

This Fixed the problem for me..

@cmcgill1988
Copy link

Any news if the PR fixing this is going to get merged in? I'm keen to use this package but until this is fixed I will have to stick with my own implementation which isn't as clean or responsive as this package.

letsar added a commit that referenced this issue May 25, 2019
@letsar
Copy link
Owner

letsar commented May 25, 2019

Thanks, published in v0.3.0

@letsar letsar closed this as completed May 25, 2019
@Wood-Water-Peng
Copy link

It's really helpful,I have fixed this problem with overriding the hitTestChildren method。
Thank you!
ps: StaggerGridView inside NestedScrollView

@mickykebe
Copy link

This solution no longer works since flutter version 1.7.

Ahmadre pushed a commit to Ahmadre/flutter_staggered_grid_view that referenced this issue Jul 10, 2019
@rajesh-kc
Copy link

Upgraded flutter to 1.7 v, Now flutter_staggered_grid_view package is throwing this error "Unhandled Exception: type 'SliverHitTestResult' is not a subtype of type 'BoxHitTestResult'"

Upgraded package to 0.3.0 from 0.2.7, The error remains the same.

Requesting the author to provide a solution.

pzgz added a commit to pzgz/flutter_staggered_grid_view that referenced this issue Jul 11, 2019
pzgz added a commit to pzgz/flutter_staggered_grid_view that referenced this issue Jul 11, 2019
pzgz added a commit to pzgz/flutter_staggered_grid_view that referenced this issue Jul 11, 2019
@miguelangarano
Copy link

@dereklakin 's solution works like a charm for me in Flutter 1.7.8+hotfix.3 and last updated Staggered package

@udit-wynk
Copy link

facing the same issue with Flutter 1.7.8+hotfix.3 and flutter_staggered_grid_view 0.3.0.
Please provide with a fix..

@sinuraya
Copy link

here is work for me:

  1. uprgade flutter_staggered_grid_view to 0.3.0
  2. if the problem still persist, delete ~/.pub-cache/hosted/pub.dartlang.org folder
  3. run $ flutter pub get
  4. your flutter_staggered_grid_view should work by now

@xhidnoda
Copy link

After upgrade to 0.3.0 on Flutter 1.7.8. Running flutter clean works for me.

@nixoncode
Copy link

After upgrade to 0.3.0 on Flutter 1.7.8. Running flutter clean works for me.

This worked for me

@sunderls
Copy link

sunderls commented Aug 2, 2019

above works!

@gateshibill
Copy link

update flutter_staggered_grid_view: ^0.3.0,it is ok!

@ghost
Copy link

ghost commented Jan 16, 2020

update flutter_staggered_grid_view: ^0.3.0,it is ok!

its is working, nice thankyou !

@dongzhixuanyuan
Copy link

After upgrade to 0.3.0. Running flutter clean works for me. must run flutter clean

@w4t3r-45
Copy link

here is work for me:

  1. uprgade flutter_staggered_grid_view to 0.3.0
  2. if the problem still persist, delete ~/.pub-cache/hosted/pub.dartlang.org folder
  3. run $ flutter pub get
  4. your flutter_staggered_grid_view should work by now

thaaaaaaaaaaaaaank you so much maaan my head burned trying to fix it and now all is working i just updated it to 0.3.0 thaaaaaaaaaaank you maaaaan

@tibfox
Copy link

tibfox commented Jul 16, 2020

here is work for me:

1. uprgade flutter_staggered_grid_view to 0.3.0

2. if the problem still persist, delete ~/.pub-cache/hosted/pub.dartlang.org folder

3. run $ flutter pub get

4. your flutter_staggered_grid_view should work by now

thank you!

@GirijeshGupta
Copy link

Ya, it's work for me after upgrade 0.3.0

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

No branches or pull requests