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

fix: Fix overlayEntry crash #98

Merged
merged 2 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/flutter_playground/lib/left_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class LeftMenu extends StatelessWidget {
createMenu(context, 'Textfield Examples', textFieldExample),
createMenu(context, 'Wrap Examples', wrapExample),
createMenu(context, 'stackExample', stackExample),
createMenu(context, 'overlayEntry Example', overlayEntryExample),
createMenu(context, 'OverlayEntry Examples', overlayEntryExample),
createMenu(context, 'Slider Examples', sliderExample),
createMenu(context, 'Text Example', textExample),
Expand Down
121 changes: 70 additions & 51 deletions examples/flutter_playground/lib/pages/overlay_entry_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,94 @@ class OverlayEntryExample extends StatefulWidget {
class _OverlayEntryExampleState extends State<OverlayEntryExample> {
Widget test = const SizedBox.shrink();
bool showOverlay = false;
bool showOverlay3 = true;
bool showOverlay2 = true;
jonas-martinez marked this conversation as resolved.
Show resolved Hide resolved
bool removeOverlays = false;

@override
Widget build(BuildContext context) {
return Center(
child: LenraFlex(
direction: Axis.vertical,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 2,
children: [
LenraText(text: "You can show another overlay by clicking on the button below."),
LenraButton(
text: "Show",
onPressed: () {
setState(() {
showOverlay = true;
});
},
LenraFlex(
spacing: 2,
children: [
LenraButton(
text: "Show",
onPressed: () {
setState(() {
showOverlay = true;
removeOverlays = false;
});
},
),
LenraButton(
text: "Remove overlays",
onPressed: () {
setState(() {
removeOverlays = true;
});
},
),
],
),
LenraOverlayEntry(
showOverlay: showOverlay,
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: Container(
child: Center(
child: Container(
color: LenraColorThemeData.greyNature,
if (!removeOverlays) ...[
LenraOverlayEntry(
showOverlay: showOverlay,
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: Container(
child: Center(
child: Container(
color: LenraColorThemeData.greyNature,
child: LenraFlex(
direction: Axis.vertical,
padding: EdgeInsets.all(2),
spacing: 2,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LenraText(text: "This is an overlay entry"),
LenraButton(
text: "Close",
onPressed: () {
setState(() {
showOverlay = false;
});
},
),
],
),
),
),
),
),
),
LenraOverlayEntry(
showOverlay: showOverlay2,
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: Container(
color: LenraColorThemeData.greyLight,
child: Center(
child: LenraFlex(
direction: Axis.vertical,
spacing: 2,
direction: Axis.vertical,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LenraText(text: "This is an overlay entry"),
LenraText(text: "This is an overlay."),
LenraText(text: "You can close it by clicking on the button."),
LenraButton(
text: "Close",
onPressed: () {
setState(() {
showOverlay = false;
showOverlay2 = false;
});
},
),
Expand All @@ -63,37 +112,7 @@ class _OverlayEntryExampleState extends State<OverlayEntryExample> {
),
),
),
),
LenraOverlayEntry(
showOverlay: showOverlay3,
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: Container(
color: LenraColorThemeData.greyLight,
child: Center(
child: LenraFlex(
spacing: 2,
direction: Axis.vertical,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LenraText(text: "This is an overlay."),
LenraText(text: "You can close it by clicking on the button."),
LenraButton(
text: "Close",
onPressed: () {
setState(() {
showOverlay3 = false;
});
},
),
],
),
),
),
),
),
]
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/layout/lenra_overlay_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _LenraOverlayEntryState extends State<LenraOverlayEntry> {
@override
void deactivate() {
super.deactivate();
if (overlayEntry.mounted) {
if (widget.showOverlay == true && overlayEntry.mounted) {
jonas-martinez marked this conversation as resolved.
Show resolved Hide resolved
removeOverlay();
}
}
Expand Down