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

_onGetSize getting called with dirty context #2

Closed
Mayb3Nots opened this issue May 10, 2021 · 5 comments
Closed

_onGetSize getting called with dirty context #2

Mayb3Nots opened this issue May 10, 2021 · 5 comments

Comments

@Mayb3Nots
Copy link

Error at

void _onGetSize(_) {
Size? size;
RenderObject? renderObject = context.findRenderObject();
if (renderObject != null) {
Rect bounds = renderObject.paintBounds;
size = bounds.size;
}
_calcCurrentPixels();
onGetSize(size);
}

I/flutter (26103): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (26103): The following assertion was thrown during a scheduler callback:
I/flutter (26103): This widget has been unmounted, so the State no longer has a context (and should be considered
I/flutter (26103): defunct).
I/flutter (26103): Consider canceling any active work during "dispose" or using the "mounted" getter to determine if
I/flutter (26103): the State is still active.
I/flutter (26103):
I/flutter (26103): When the exception was thrown, this was the stack:
I/flutter (26103): #0      State.context.<anonymous closure>
package:flutter/…/widgets/framework.dart:1088
I/flutter (26103): #1      State.context
package:flutter/…/widgets/framework.dart:1094
I/flutter (26103): #2      _TransformerPageViewState._onGetSize
package:flutter_swiper_null_safety/…/transformer_page_view/transformer_page_view.dart:444
I/flutter (26103): #3      SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1144
I/flutter (26103): #4      SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1090
I/flutter (26103): #5      SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:998
I/flutter (26103): #9      _invoke (dart:ui/hooks.dart:161:10)
I/flutter (26103): #10     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:253:5)
I/flutter (26103): #11     _drawFrame (dart:ui/hooks.dart:120:31)
I/flutter (26103): (elided 3 frames from dart:async)
I/flutter (26103): ════════════════════════════════════════════════════════════════════════════════════════════════════

@lianyagang
Copy link
Owner

Error at

void _onGetSize(_) {
Size? size;
RenderObject? renderObject = context.findRenderObject();
if (renderObject != null) {
Rect bounds = renderObject.paintBounds;
size = bounds.size;
}
_calcCurrentPixels();
onGetSize(size);
}

I/flutter (26103): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (26103): The following assertion was thrown during a scheduler callback:
I/flutter (26103): This widget has been unmounted, so the State no longer has a context (and should be considered
I/flutter (26103): defunct).
I/flutter (26103): Consider canceling any active work during "dispose" or using the "mounted" getter to determine if
I/flutter (26103): the State is still active.
I/flutter (26103):
I/flutter (26103): When the exception was thrown, this was the stack:
I/flutter (26103): #0      State.context.<anonymous closure>
package:flutter/…/widgets/framework.dart:1088
I/flutter (26103): #1      State.context
package:flutter/…/widgets/framework.dart:1094
I/flutter (26103): #2      _TransformerPageViewState._onGetSize
package:flutter_swiper_null_safety/…/transformer_page_view/transformer_page_view.dart:444
I/flutter (26103): #3      SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1144
I/flutter (26103): #4      SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1090
I/flutter (26103): #5      SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:998
I/flutter (26103): #9      _invoke (dart:ui/hooks.dart:161:10)
I/flutter (26103): #10     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:253:5)
I/flutter (26103): #11     _drawFrame (dart:ui/hooks.dart:120:31)
I/flutter (26103): (elided 3 frames from dart:async)
I/flutter (26103): ════════════════════════════════════════════════════════════════════════════════════════════════════

How do you used it

@Mayb3Nots
Copy link
Author

Mayb3Nots commented May 11, 2021

@lianyagang This is how I used it.

Swiper(
   viewportFraction: 0.85,
   itemCount: listOfCard.length,
   itemBuilder: (context, index) {
   return listOfCard[index];
          },
   scale: 0.8,
);

Please take a look at this PR https://github.com/best-flutter/transformer_page_view/pull/44/files?file-filters%5B%5D=.dart&file-filters%5B%5D=.lock&file-filters%5B%5D=.xml#diff-f64f550d7c7db79c0d5219784f2ca3cdc4edaf4fac44fe65cd01bd5ed2062fb6 it was created to fix by @Faiyyazauxy.

lianyagang added a commit that referenced this issue May 11, 2021
#2
element为空导致的渲染崩溃
@lianyagang
Copy link
Owner

https://github.com/best-flutter/transformer_page_view/pull/44/files?file-filters%5B%5D=.dart&file-filters%5B%5D=.lock&file-filters%5B%5D=.xml#diff-f64f550d7c7db79c0d5219784f2ca3cdc4edaf4fac44fe65cd01bd5ed2062fb6

i will try it ,but i can't reproduce this issue
and i push something code u can try it

if it work for u ,please tell me ,i will publish to pub.dev and upgrade version

@Mayb3Nots
Copy link
Author

https://github.com/best-flutter/transformer_page_view/pull/44/files?file-filters%5B%5D=.dart&file-filters%5B%5D=.lock&file-filters%5B%5D=.xml#diff-f64f550d7c7db79c0d5219784f2ca3cdc4edaf4fac44fe65cd01bd5ed2062fb6

i will try it ,but i can't reproduce this issue
and i push something code u can try it

if it work for u ,please tell me ,i will publish to pub.dev and upgrade version

Hi I can confirm that the lastest commit fixed my issue. Thanks

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

2 participants