I am new on Flutter and I would like to set up a form. This is my code:
const TextField(
decoration: InputDecoration(
labelText: 'Nom',
hintText: 'Entrez votre nom',
icon: Icon(
Icons.person,
color: Colors.blue,
size: 25,
),
keyboardType: TextInputType.text,
autocorrect: true,
autofocus: true,
)),
const TextField(
decoration: InputDecoration(
labelText: 'Prenom',
hintText: 'Entrez votre Prenom',
icon: Icon(
Icons.person,
color: Colors.blue,
size: 25,
),
keyboardType: TextInputType.text,
)),
const TextField(
decoration: InputDecoration(
labelText: 'Telephome',
hintText: 'Entrez votre numero de telephone',
icon: Icon(
Icons.phone,
color: Colors.blue,
size: 25,
),
keyboardType: TextInputType.number,
)),
const TextField(decoration: InputDecoration(
labelText: 'Mot de passe',
hintText: 'Entrez votre mot de passe',
icon: Icon(
Icons.lock,
color: Colors.red,
size: 25,
),
keyboardType: TextInputType.visiblePassword,
ObscureText: true,
)),
when i run i see this error:
lib/main.dart:48:15: Error: No named parameter with the name 'keyboardType'. keyboardType: TextInputType.text, ^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: Context: Found this candidate, but the arguments don't match. const InputDecoration({ ^^^^^^^^^^^^^^^ lib/main.dart:61:15: Error: No named parameter with the name 'keyboardType'. keyboardType: TextInputType.text, ^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: Context: Found this candidate, but the arguments don't match. const InputDecoration({ ^^^^^^^^^^^^^^^ lib/main.dart:72:15: Error: No named parameter with the name 'keyboardType'. keyboardType: TextInputType.number, ^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: Context: Found this candidate, but the arguments don't match. const InputDecoration({ ^^^^^^^^^^^^^^^ lib/main.dart:82:15: Error: No named parameter with the name 'keyboardType'. keyboardType: TextInputType.visiblePassword, ^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: Context: Found this candidate, but the arguments don't match. const InputDecoration({ ^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:273:21: Error: The method 'ancestorWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'ancestorWidgetOfExactType'. return context?.ancestorWidgetOfExactType(SmartRefresher); ^^^^^^^^^^^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:277:41: Error: Method not found: 'TypeMatcher'. return context?.ancestorStateOfType(TypeMatcher()); ^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:277:21: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'. return context?.ancestorStateOfType(TypeMatcher()); ^^^^^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:1003:20: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'. return context.inheritFromWidgetOfExactType(RefreshConfiguration); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/internals/indicator_wrap.dart:631:9: Error: A value of type 'ValueNotifier' can't be assigned to a variable of type 'ValueNotifier'.
- 'ValueNotifier' is from 'package:flutter/src/foundation/change_notifier.dart' ('../../flutter/packages/flutter/lib/src/foundation/change_notifier.dart'). ? refresher.controller.headerMode
please help me
CodePudding user response:
Try below code I think your problem has been solved. refer Textfield
CodePudding user response:
TextFormField(
keyboardType: TextInputType.number,
controller: stepcontroller,
focusNode: _focusNodes[0],
decoration: InputDecoration(
labelText: "Enter Step",
labelStyle: TextStyle(
color: _focusNodes[0].hasFocus
? appcolor
: Colors.grey,
// fontSize: 24.0
),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: appcolor, width: 2.0),
// borderRadius: BorderRadius.circular(25.0),
),
// prefixIcon: Icon(
// Icons.person,
// color: _focusNodes[0].hasFocus
// ? Colors.teal
// : Colors.grey,
// ),
),
validator: (value) {
if (value.isEmpty) {
return " Step cant be empty";
} else if (value.length > contactlist.length) {
return "step out of range";
}
},
),
You can try this, it will open numbers keyboard
CodePudding user response:
Refer this link to clear understand about textfiled
properties in Flutter.
https://api.flutter.dev/flutter/material/TextField-class.html