-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_fields.dart
104 lines (101 loc) · 3.58 KB
/
input_fields.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class MyInputField extends StatelessWidget {
final String title;
final String hint;
final TextEditingController? controller;
final Widget? widget;
final bool? isMax;
final bool? isInputNumber;
final bool? isMAX;
const MyInputField(
{super.key,
required this.title,
required this.hint,
this.isMax,
this.controller,
this.widget,
this.isInputNumber,
this.isMAX});
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
// color: Get.isDarkMode ? Colors.white : Colors.black
color: Colors.black),
),
Container(
height: 52,
padding: const EdgeInsets.only(left: 14.0),
margin: const EdgeInsets.only(top: 8.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade600, width: 01.0),
borderRadius: BorderRadius.circular(12)),
child: Row(
children: [
Expanded(
child: TextFormField(
//length can be modified
maxLength: isMax == true
? 255
: isMAX == true
? 12
: null,
readOnly: widget == null ? false : true,
inputFormatters: isMAX == true
? [FilteringTextInputFormatter.digitsOnly]
: [],
autofocus: false,
keyboardType:
isInputNumber == true ? TextInputType.number : null,
cursorColor: Colors.black,
controller: controller,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black),
decoration: InputDecoration(
//counter text is showing the number of characters left....
counterText: "",
hintText: hint,
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.grey.shade700),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
//color: Colors.backgroundColor
// color: Theme.of(context).colorScheme.background,
width: 0,
color: Colors.transparent),
),
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
//color: Colors.backgroundColor
width: 0,
color: Colors.transparent),
),
),
),
),
widget == null
? Container()
: Container(
child: widget,
)
],
),
),
],
),
);
}
}