Skip to content

Commit c4bfea8

Browse files
Merge pull request #18 from DevCrew-io/add_max_min_lines
add property for max lines & min lines
2 parents c2276ed + c6dfb04 commit c4bfea8

File tree

4 files changed

+52
-38
lines changed

4 files changed

+52
-38
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.5
2+
* Add property for max lines and min lines
3+
14
## 1.0.5
25
* Add text alignment and vertical text alignment to MaterialTextField.
36

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class _MyHomePageState extends State<MyHomePage> {
7171
keyboardType: TextInputType.text,
7272
hint: "Full Name",
7373
labelText: "Name",
74+
maxLines: 1,
7475
theme: FilledOrOutlinedTextTheme(
7576
enabledColor: Colors.grey,
7677
focusedColor: Colors.green,

lib/material_text_fields.dart

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -122,43 +122,51 @@ class MaterialTextField extends StatelessWidget {
122122
/// The vertical alignment of text within an input box.
123123
final TextAlignVertical? textAlignVertical;
124124

125-
const MaterialTextField({
126-
Key? key,
127-
this.textAlign = TextAlign.start,
128-
this.textAlignVertical,
129-
this.keyboardType,
130-
this.controller,
131-
this.validator,
132-
this.textInputAction,
133-
this.suffixIcon,
134-
this.prefixIcon,
135-
this.hint,
136-
this.obscureText = false,
137-
this.enabled = true,
138-
this.onChanged,
139-
this.style,
140-
this.icon,
141-
this.iconColor,
142-
this.errorStyle,
143-
this.errorMaxLines,
144-
this.errorText,
145-
this.floatingLabelAlignment,
146-
this.floatingLabelBehavior,
147-
this.helperMaxLines,
148-
this.helperStyle,
149-
this.helperText,
150-
this.hintMaxLines,
151-
this.hintTextDirection,
152-
this.suffixIconColor,
153-
this.prefixIconColor,
154-
this.prefixStyle,
155-
this.prefixText,
156-
this.suffixStyle,
157-
this.suffixText,
158-
this.labelText,
159-
this.theme,
160-
this.maxLength,
161-
}) : super(key: key);
125+
/// Max lines for the text field
126+
int? maxLines = 1;
127+
128+
/// Min lines for the text field
129+
final int? minLines;
130+
131+
MaterialTextField(
132+
{Key? key,
133+
this.textAlign = TextAlign.start,
134+
this.textAlignVertical,
135+
this.keyboardType,
136+
this.controller,
137+
this.validator,
138+
this.textInputAction,
139+
this.suffixIcon,
140+
this.prefixIcon,
141+
this.hint,
142+
this.obscureText = false,
143+
this.enabled = true,
144+
this.onChanged,
145+
this.style,
146+
this.icon,
147+
this.iconColor,
148+
this.errorStyle,
149+
this.errorMaxLines,
150+
this.errorText,
151+
this.floatingLabelAlignment,
152+
this.floatingLabelBehavior,
153+
this.helperMaxLines,
154+
this.helperStyle,
155+
this.helperText,
156+
this.hintMaxLines,
157+
this.hintTextDirection,
158+
this.suffixIconColor,
159+
this.prefixIconColor,
160+
this.prefixStyle,
161+
this.prefixText,
162+
this.suffixStyle,
163+
this.suffixText,
164+
this.labelText,
165+
this.theme,
166+
this.maxLength,
167+
this.maxLines,
168+
this.minLines})
169+
: super(key: key);
162170

163171
@override
164172
Widget build(BuildContext context) {
@@ -207,6 +215,8 @@ class MaterialTextField extends StatelessWidget {
207215
style: style,
208216
textInputAction: textInputAction,
209217
maxLength: maxLength,
218+
maxLines: obscureText ? 1 : maxLines,
219+
minLines: minLines,
210220
);
211221
}
212222
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: material_text_fields
22
description: Material Text Field is a customizable widget for text input values in Dart.
3-
version: 1.0.5
3+
version: 1.0.6
44
homepage: https://github.com/DevCrew-io/material-text-fields#readme
55
repository: https://github.com/DevCrew-io/material-text-fields
66
issue_tracker: https://github.com/DevCrew-io/material-text-fields/issues

0 commit comments

Comments
 (0)