flutter - 颤振错误:没有名称为“keyboardType”的命名参数。键盘类型:TextInputType.text
问题描述
我是 Flutter 的新手,我想设置一个表单。这是我的代码:
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,
)),
当我运行时,我看到了这个错误:
lib/main.dart:48:15:错误:没有名为“keyboardType”的命名参数。键盘类型:TextInputType.text,^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9:上下文:找到这个候选人,但论点不匹配。const InputDecoration({ ^^^^^^^^^^^^^^^ lib/main.dart:61:15: 错误: 没有名为“keyboardType”的命名参数。keyboardType: TextInputType.text, ^^^ ^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: 上下文:找到了这个候选人,但参数不匹配。 InputDecoration({ ^^^^^^^^^^^^^^^ lib/main.dart:72:15: 错误: 没有名为“keyboardType”的命名参数。keyboardType: TextInputType.number, ^^^^ ^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: 上下文:找到了这个候选人,但论点不匹配。const InputDecoration({ ^^^^^^^^^^^^^^^ lib/main.dart:82:15: 错误: 没有名为“keyboardType”的命名参数。keyboardType: TextInputType.visiblePassword, ^^^ ^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9: 上下文:找到了这个候选人,但参数不匹配。 InputDecoration({ ^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/smart_refresher .dart:273:21:错误:没有为类“BuildContext”定义方法“ancestorWidgetOfExactType”。^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9:上下文:找到了这个候选人,但论点没有匹配。const InputDecoration({ ^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/ smart_refresher.dart:273:21:错误:没有为类“BuildContext”定义方法“ancestorWidgetOfExactType”。^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/material/input_decorator.dart:2522:9:上下文:找到了这个候选人,但论点没有匹配。const InputDecoration({ ^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/ smart_refresher.dart:273:21:错误:没有为类“BuildContext”定义方法“ancestorWidgetOfExactType”。
- “BuildContext”来自“package:flutter/src/widgets/framework.dart”(“../../flutter/packages/flutter/lib/src/widgets/framework.dart”)。尝试将名称更正为现有方法的名称,或定义名为“ancestorWidgetOfExactType”的方法。返回上下文?.ancestorWidgetOfExactType(SmartRefresher); ^^^^^^^^^^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6。 3/lib/src/smart_refresher.dart:277:41:错误:找不到方法:'TypeMatcher'。返回上下文?.ancestorStateOfType(TypeMatcher()); ^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:277:21:错误:没有为类“BuildContext”定义方法“ancestorStateOfType”。
- “BuildContext”来自“package:flutter/src/widgets/framework.dart”(“../../flutter/packages/flutter/lib/src/widgets/framework.dart”)。尝试将名称更正为现有方法的名称,或定义名为“ancestorStateOfType”的方法。返回上下文?.ancestorStateOfType(TypeMatcher()); ^^^^^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.3/lib/src/ smart_refresher.dart:1003:20:错误:没有为类“BuildContext”定义方法“inheritFromWidgetOfExactType”。
- “BuildContext”来自“package:flutter/src/widgets/framework.dart”(“../../flutter/packages/flutter/lib/src/widgets/framework.dart”)。尝试将名称更正为现有方法的名称,或定义名为“inheritFromWidgetOfExactType”的方法。返回 context.inheritFromWidgetOfExactType(RefreshConfiguration); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh -1.6.3/lib/src/internals/indicator_wrap.dart:631:9:错误:“ValueNotifier”类型的值不能分配给“ValueNotifier”类型的变量。
- “ValueNotifier”来自“package:flutter/src/foundation/change_notifier.dart”(“../../flutter/packages/flutter/lib/src/foundation/change_notifier.dart”)。? refresher.controller.headerMode
请帮我
解决方案
试试下面的代码,我认为你的问题已经解决了。在此处参考文本字段
TextField(
keyboardType: TextInputType.text,
autocorrect: true,
autofocus: true,
decoration: InputDecoration(
labelText: 'Nom',
hintText: 'Entrez votre nom',
icon: Icon(
Icons.person,
color: Colors.blue,
size: 25,
),
),
),
TextField(
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: 'Prenom',
hintText: 'Entrez votre Prenom',
icon: Icon(
Icons.person,
color: Colors.blue,
size: 25,
),
),
),
TextField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Telephome',
hintText: 'Entrez votre numero de telephone',
icon: Icon(
Icons.phone,
color: Colors.blue,
size: 25,
),
),
),
TextField(
keyboardType: TextInputType.visiblePassword,
obscureText: true,
decoration: InputDecoration(
labelText: 'Mot de passe',
hintText: 'Entrez votre mot de passe',
icon: Icon(
Icons.lock,
color: Colors.red,
size: 25,
),
),
),