1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import 'package:flutter/material.dart';
- class VInput extends StatelessWidget {
- final String? placeholder;
- final String? initialValue;
- final TextEditingController? controller;
- final FocusNode? focusNode;
- final ValueChanged<String>? onChanged;
- final VoidCallback? onTap;
- final bool? readOnly;
- final double? radius;
- const VInput({
- super.key,
- this.initialValue,
- this.controller,
- this.focusNode,
- this.placeholder,
- this.onChanged,
- this.onTap,
- this.readOnly = false,
- this.radius,
- });
- @override
- Widget build(BuildContext context) {
- final c = controller ?? TextEditingController(text: initialValue);
- final borderRadius = BorderRadius.all(Radius.circular(radius ?? 0));
- return TextField(
- controller: c,
- textAlign: TextAlign.start,
- textAlignVertical: TextAlignVertical.center,
- decoration: InputDecoration(
- enabledBorder: OutlineInputBorder(
- borderRadius: borderRadius,
- borderSide: const BorderSide(color: Colors.grey),
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: borderRadius,
- borderSide: BorderSide(color: Theme.of(context).primaryColor),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: borderRadius,
- borderSide: BorderSide(color: Theme.of(context).colorScheme.error),
- ),
- // errorText: "112323",
- errorMaxLines: 1,
- fillColor: Colors.white,
- filled: true,
- hintText: placeholder,
- hintStyle: const TextStyle(
- fontSize: 16,
- color: Colors.black54,
- ),
- contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 0),
- // isDense: true,
- isCollapsed: false,
- ),
- onChanged: (value) {
- onChanged?.call(value);
- },
- onTap: () {
- onTap?.call();
- },
- readOnly: readOnly!,
- );
- }
- }
|