flutter_inner_drawer
flutter_inner_drawer copied to clipboard
Problems in showing the content of the drawer in CuportinoScaffold
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.
Hi @andreacimino, I'll try to do some tests and let you know. Thanks
@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;
});
});
}
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.
@andreacimino the fix you recommended works correctly. I released a new version 0.5.5+1, try it and let me know. thanks
@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.
Thank you for the hints! I will try the latest version and see if everything works fine.