mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Ensure padding around suffix icons.
This commit is contained in:
parent
b37d19164d
commit
d8debd239a
@ -64,28 +64,38 @@ class AppInputDecoration extends InputDecoration {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget? get suffixIcon {
|
Widget? get suffixIcon {
|
||||||
final hasError = errorText != null;
|
final icons = [
|
||||||
|
if (super.suffixIcon != null) super.suffixIcon!,
|
||||||
|
if (suffixIcons != null) ...suffixIcons!,
|
||||||
|
if (errorText != null) const Icon(Icons.error_outlined),
|
||||||
|
];
|
||||||
|
|
||||||
if (hasError || suffixIcons != null) {
|
return switch (icons.length) {
|
||||||
final errorIcon = hasError ? const Icon(Icons.error_outlined) : null;
|
0 => null,
|
||||||
|
1 => icons.single,
|
||||||
final existingSuffixIcon = super.suffixIcon;
|
_ => Builder(
|
||||||
|
builder: (context) {
|
||||||
if (errorIcon != null &&
|
// Apply the constraints to *each* icon.
|
||||||
(existingSuffixIcon == null && suffixIcons == null)) {
|
final constraints = suffixIconConstraints ??
|
||||||
return errorIcon;
|
Theme.of(context).visualDensity.effectiveConstraints(
|
||||||
}
|
const BoxConstraints(
|
||||||
return Wrap(
|
minWidth: kMinInteractiveDimension,
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
minHeight: kMinInteractiveDimension,
|
||||||
runAlignment: WrapAlignment.center,
|
),
|
||||||
children: [
|
);
|
||||||
if (suffixIcons != null) ...suffixIcons!,
|
return Wrap(
|
||||||
if (existingSuffixIcon != null) existingSuffixIcon,
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
if (errorIcon != null) ...[errorIcon, const SizedBox(width: 8.0)],
|
runAlignment: WrapAlignment.center,
|
||||||
],
|
children: [
|
||||||
);
|
for (Widget icon in icons)
|
||||||
}
|
ConstrainedBox(
|
||||||
|
constraints: constraints,
|
||||||
return super.suffixIcon;
|
child: icon,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user