Skip to content

Commit

Permalink
Added the color_picker closing callback to the `BackButtonInterceptor…
Browse files Browse the repository at this point in the history
…` with the proper priority
  • Loading branch information
B-Saeid committed Dec 21, 2024
1 parent 6a3ddfd commit d1b4f3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion feedback/lib/src/color_picker/color_picker_icon.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:math';

import 'package:feedback/src/utilities/back_button_interceptor.dart';
import 'package:flutter/material.dart';

part 'alpha_slider.dart';
Expand Down Expand Up @@ -121,5 +122,8 @@ class ColorPickerIcon extends StatelessWidget {
overlayState.insert(_entry!);
}

void _close() => _entry?.remove();
bool _close() {
_entry?.remove();
return true;
}
}
9 changes: 8 additions & 1 deletion feedback/lib/src/color_picker/overlay_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class _OverlayStack extends StatefulWidget {
required this.onColorChanged,
});

final VoidCallback closeCallback;
final BoolCallback closeCallback;
final Color activeColor;
final ValueChanged<Color> onColorChanged;

Expand All @@ -21,6 +21,7 @@ class _OverlayStackState extends State<_OverlayStack> {
@override
void initState() {
super.initState();
BackButtonInterceptor.add(widget.closeCallback, priority: 1);
Future(() => setState(() => opacity = 1.0));
}

Expand All @@ -33,6 +34,12 @@ class _OverlayStackState extends State<_OverlayStack> {
);
}

@override
void dispose() {
BackButtonInterceptor.remove(widget.closeCallback);
super.dispose();
}

@override
Widget build(BuildContext context) => Stack(
alignment: Alignment.center,
Expand Down

0 comments on commit d1b4f3a

Please sign in to comment.