43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class GeneralInputDecoration {
|
|
static InputDecoration getCustomDecoration({
|
|
required BuildContext context,
|
|
required String hintText,
|
|
String? labelText,
|
|
Widget? suffixIcon,
|
|
Widget? prefixIcon,
|
|
String? errorMsg,
|
|
}) {
|
|
Color? borderColor = errorMsg != null ? Colors.red : Colors.grey;
|
|
return InputDecoration(
|
|
labelText: labelText,
|
|
suffixIcon: suffixIcon,
|
|
prefixIcon: prefixIcon,
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
borderSide: BorderSide(color: borderColor),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(15),
|
|
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
|
|
),
|
|
errorBorder: OutlineInputBorder(
|
|
// Border when there's an error
|
|
borderRadius: BorderRadius.circular(20),
|
|
borderSide: BorderSide(color: Theme.of(context).colorScheme.error),
|
|
),
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
// Border when focused with error
|
|
borderRadius: BorderRadius.circular(20),
|
|
borderSide: BorderSide(color: Theme.of(context).colorScheme.error),
|
|
),
|
|
fillColor: Colors.grey.shade200,
|
|
filled: true,
|
|
hintText: hintText,
|
|
hintStyle: TextStyle(color: Colors.grey[500]),
|
|
errorText: errorMsg,
|
|
);
|
|
}
|
|
}
|