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

Problems in showing the content of the drawer in CuportinoScaffold #33

Open
andreacimino opened this issue Apr 28, 2020 · 6 comments
Open
Labels
bug Something isn't working

Comments

@andreacimino
Copy link

andreacimino commented Apr 28, 2020

Hello, thank you for the wonderful package!.
I struggled a lot to make work the package under Cupertino.
After some debugging i found the problem:

In line 267 you have

final RenderBox box = _drawerKey.currentContext?.findRenderObject();
The problem is that the drawerKey context is not always the context of the widget.
I managed to solve by changing the signature of the method to:

void _updateWidth(BuildContext context) {
}

And then calling:

 @override
  Widget build(BuildContext context) {
    //assert(debugCheckHasMaterialLocalizations(context));

    /// initialize the correct width
    if (_initWidth == 400 ||
        MediaQuery.of(context).orientation != _orientation) {
      _updateWidth(context); <---- /*here the change*/
      _orientation = MediaQuery.of(context).orientation;
    }

I am not sending a pull request, since I don't know if this change would break something, thanks.

@Dn-a
Copy link
Owner

Dn-a commented Apr 28, 2020

Hi @andreacimino, I'll try to do some tests and let you know.
Thanks

@Dn-a Dn-a added the bug Something isn't working label Apr 28, 2020
@Dn-a
Copy link
Owner

Dn-a commented Apr 28, 2020

@andreacimino specifically, is this the change you made?

void _updateWidth(BuildContext context) {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      //final RenderBox box = _drawerKey.currentContext.findRenderObject();
      final RenderBox box = context.findRenderObject();
      if (box != null && box.size != null)
        setState(() {
          _initWidth = box.size.width;
        });
    });
  }

@andreacimino
Copy link
Author

Almost yes, you can check the version I am using right now.
I needed to handle the initState call, passing with null.
Please look at the attached file.

inner_drawer.dart.zip

Dn-a added a commit that referenced this issue Apr 28, 2020
@Dn-a
Copy link
Owner

Dn-a commented Apr 28, 2020

@andreacimino the fix you recommended works correctly. I released a new version 0.5.5+1, try it and let me know. thanks

Dn-a added a commit that referenced this issue Apr 29, 2020
@Dn-a
Copy link
Owner

Dn-a commented Apr 29, 2020

@andreacimino I have done other tests and unfortunately your solution produces side effects. The code is again as before with the addition of a small modification. Small precautions: every time you update a package, before compiling, uninstall the app from the Android emulator.

@andreacimino
Copy link
Author

Thank you for the hints! I will try the latest version and see if everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants