fix: ontap not working when custom header is set

This commit is contained in:
Jacques Doeleman 2022-10-26 16:39:47 +02:00
parent 610012ca5b
commit 485e1c6952
3 changed files with 57 additions and 43 deletions

View file

@ -1,3 +1,11 @@
## 0.0.1 ## 0.0.1
- Initial port - Initial port
## 0.0.2
- Updated flutter_form version
## 0.0.3
- Fixed bug where onTap was not working when header is set

View file

@ -134,14 +134,48 @@ class MediaPicker extends ConsumerWidget {
children: [ children: [
for (final input in inputs) ...[ for (final input in inputs) ...[
const SizedBox(height: 2.5), const SizedBox(height: 2.5),
header?.call(input.label, input.onPressed) ?? header?.call(input.label, (BuildContext ct) async {
await onPressedMediaType(ct, input);
}) ??
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
await onPressedMediaType(context, input);
},
child: Container(
height: 55,
width: MediaQuery.of(context).size.width * 0.9,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xFF979797),
width: 1,
),
),
),
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Text(
input.label,
style: Theme.of(context).textTheme.headline6,
),
),
),
),
),
const SizedBox(height: 2.5),
],
],
);
}
Future<void> onPressedMediaType(
BuildContext context, MediaPickerInput input) async {
MediaResult content = await input.onPressed(context); MediaResult content = await input.onPressed(context);
if (mediaCheckPage != null && if (mediaCheckPage != null &&
(input.runtimeType == MediaPickerInputText || (input.runtimeType == MediaPickerInputText || _hasContent(content))) {
_hasContent(content))) {
var checkPage = mediaCheckPage!( var checkPage = mediaCheckPage!(
await input.displayResult(content), await input.displayResult(content),
input.checkPageSettings, input.checkPageSettings,
@ -178,34 +212,6 @@ class MediaPicker extends ConsumerWidget {
onComplete!(content); onComplete!(content);
} }
} }
},
child: Container(
height: 55,
width: MediaQuery.of(context).size.width * 0.9,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xFF979797),
width: 1,
),
),
),
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Text(
input.label,
style: Theme.of(context).textTheme.headline6,
),
),
),
),
),
const SizedBox(height: 2.5),
],
],
);
} }
bool _hasContent(MediaResult content) { bool _hasContent(MediaResult content) {