Add a input type
This commit is contained in:
parent
e351f30d4a
commit
65d70a4f6d
4 changed files with 24 additions and 9 deletions
|
@ -1,21 +1,25 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
///
|
||||
enum InputPromptType { Text, Number }
|
||||
|
||||
/// Prompt which enables the input of data
|
||||
class InputPrompt extends StatefulWidget {
|
||||
String title;
|
||||
String prompt;
|
||||
String currentValue;
|
||||
InputPromptType type;
|
||||
|
||||
InputPrompt(
|
||||
{super.key,
|
||||
required this.title,
|
||||
required this.prompt,
|
||||
required this.currentValue});
|
||||
required this.currentValue,
|
||||
required this.type});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return InputPromptState(
|
||||
title: title, prompt: prompt, currentValue: currentValue);
|
||||
title: title, prompt: prompt, currentValue: currentValue, type: type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,10 +27,14 @@ class InputPromptState extends State<InputPrompt> {
|
|||
String title;
|
||||
String prompt;
|
||||
String currentValue;
|
||||
InputPromptType type;
|
||||
TextEditingController textField = TextEditingController();
|
||||
|
||||
InputPromptState(
|
||||
{required this.title, required this.prompt, required this.currentValue}) {
|
||||
{required this.title,
|
||||
required this.prompt,
|
||||
required this.currentValue,
|
||||
required this.type}) {
|
||||
textField.text = currentValue;
|
||||
}
|
||||
|
||||
|
@ -40,9 +48,15 @@ class InputPromptState extends State<InputPrompt> {
|
|||
child: Column(
|
||||
children: [
|
||||
Text(prompt),
|
||||
TextField(
|
||||
controller: textField,
|
||||
)
|
||||
if (type == InputPromptType.Text)
|
||||
TextField(
|
||||
controller: textField,
|
||||
),
|
||||
if (type == InputPromptType.Number)
|
||||
TextField(
|
||||
controller: textField,
|
||||
keyboardType: TextInputType.number,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue