user input in Dart code example
Example 1: dart get String input from user
import 'dart:io';
void main()
{
print("Enter your name?");
String name = stdin.readLineSync();
print("Hello, $name! \nWelcome to GeeksforGeeks!!");
}
Example 2: how to take user input in a flutter app
For userinput, we have a widget called TextField(), An example is given below:
- The decoration field, is self explanatory.
- The labelText: tells user about what he/she has to provide in the respective TextField().
TextField(
decoration: InputDecoration(labelText: 'Title'),
),