Skip to content

Commit

Permalink
fix: Added unfocus in form widget to hide keypad on tapping the widget
Browse files Browse the repository at this point in the history
  • Loading branch information
i-asimkhan committed Jan 16, 2024
1 parent 0235ca0 commit d14e6c9
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/mirai/lib/src/parsers/mirai_form/mirai_form_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ class MiraiFormParser extends MiraiParser<MiraiForm> {
return BlocProvider(
create: (_) => MiraiFormCubit(),
child: Form(
autovalidateMode: model.autovalidateMode,
child: BlocBuilder<MiraiFormCubit, MiraiFormState>(
builder: (context, state) {
return Mirai.fromJson(model.child, context) ?? const SizedBox();
},
)),
autovalidateMode: model.autovalidateMode,
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);

if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Container(
color: Colors.transparent,
child: BlocBuilder<MiraiFormCubit, MiraiFormState>(
builder: (context, state) {
return Mirai.fromJson(model.child, context) ?? const SizedBox();
},
),
),
),
),
);
}
}

0 comments on commit d14e6c9

Please sign in to comment.