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

Does not work in profile mode #8

Open
sujanbhattaraiofficial opened this issue Aug 13, 2020 · 1 comment
Open

Does not work in profile mode #8

sujanbhattaraiofficial opened this issue Aug 13, 2020 · 1 comment

Comments

@sujanbhattaraiofficial
Copy link

In my case it looks fine in debug mode but when I run the app as profile mode it throws an exception

E/flutter ( 4423): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Failed 
assertion: boolean expression must not be null
E/flutter ( 4423): #0      _PageTurnWidgetState._captureImage (package:page_turn/src/builders/widget.dart:40)
E/flutter ( 4423): #1      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113)
E/flutter ( 4423): #2      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1060)
E/flutter ( 4423): #3      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:968)
E/flutter ( 4423): #4      _rootRun (dart:async/zone.dart:1184)
E/flutter ( 4423): #5      _CustomZone.run (dart:async/zone.dart:1077)
E/flutter ( 4423): #6      _CustomZone.runGuarded (dart:async/zone.dart:979)
E/flutter ( 4423): #7      _invoke (dart:ui/hooks.dart:261)
E/flutter ( 4423): #8      _drawFrame (dart:ui/hooks.dart:219)
E/flutter ( 4423): 
@gabrimacedo
Copy link

gabrimacedo commented Oct 4, 2020

I think its because of the "boundary.debugNeedsPaint" boolean in "_captureImage" function. If you look at docs, it says it should only be used for tests and asserts since it is only set in debug mode.

So simply comment out the boolen, and it should work fine.

void _captureImage(Duration timeStamp) async {
    final pixelRatio = MediaQuery.of(context).devicePixelRatio;
 final boundary =
        _boundaryKey.currentContext.findRenderObject() as RenderRepaintBoundary;
    // if (boundary.debugNeedsPaint) {
    //   await Future.delayed(const Duration(milliseconds: 20));
    //   return _captureImage(timeStamp);
    // }
    final image = await boundary.toImage(pixelRatio: pixelRatio);
    setState(() => _image = image);
  }

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