refactor: remove useless onTap and don't pass popovermutex when not needed

This commit is contained in:
Cyrine-benabid 2022-10-30 20:30:38 +01:00
parent 339e3d242f
commit 286c89bf74

View File

@ -43,9 +43,7 @@ class SelectOptionTypeOptionWidget extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
List<Widget> children = [ List<Widget> children = [
const TypeOptionSeparator(), const TypeOptionSeparator(),
OptionTitle( const OptionTitle(),
popoverMutex: popoverMutex,
),
if (state.isEditingOption) if (state.isEditingOption)
Padding( Padding(
padding: const EdgeInsets.only(bottom: 10), padding: const EdgeInsets.only(bottom: 10),
@ -66,9 +64,7 @@ class SelectOptionTypeOptionWidget extends StatelessWidget {
} }
class OptionTitle extends StatelessWidget { class OptionTitle extends StatelessWidget {
final PopoverMutex? popoverMutex; const OptionTitle({Key? key}) : super(key: key);
const OptionTitle({this.popoverMutex, Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -84,9 +80,7 @@ class OptionTitle extends StatelessWidget {
]; ];
if (state.options.isNotEmpty && !state.isEditingOption) { if (state.options.isNotEmpty && !state.isEditingOption) {
children.add(const Spacer()); children.add(const Spacer());
children.add(_OptionTitleButton( children.add(const _OptionTitleButton());
popoverMutex: popoverMutex,
));
} }
return SizedBox( return SizedBox(
@ -99,9 +93,7 @@ class OptionTitle extends StatelessWidget {
} }
class _OptionTitleButton extends StatelessWidget { class _OptionTitleButton extends StatelessWidget {
final PopoverMutex? popoverMutex; const _OptionTitleButton({Key? key}) : super(key: key);
const _OptionTitleButton({this.popoverMutex, Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -117,7 +109,6 @@ class _OptionTitleButton extends StatelessWidget {
), ),
hoverColor: theme.hover, hoverColor: theme.hover,
onTap: () { onTap: () {
popoverMutex?.close();
context context
.read<SelectOptionTypeOptionBloc>() .read<SelectOptionTypeOptionBloc>()
.add(const SelectOptionTypeOptionEvent.addingOption()); .add(const SelectOptionTypeOptionEvent.addingOption());
@ -316,9 +307,6 @@ class _CreateOptionTextFieldState extends State<_CreateOptionTextField> {
.read<SelectOptionTypeOptionBloc>() .read<SelectOptionTypeOptionBloc>()
.add(SelectOptionTypeOptionEvent.createOption(optionName)); .add(SelectOptionTypeOptionEvent.createOption(optionName));
}, },
onTap: () {
widget.popoverMutex?.close();
},
); );
}, },
); );