Issue
I'm trying to use WhitelistingTextInputFormatter
in a TextFormField
in a Flutter app but I get
undefined name WhitelistingTextInputFormatter
Here is my code:
child: TextFormField(
keyboardType: TextInputType.number,
inputFormatters: [WhitelistingTextInputFormatter.digitsOnly],
decoration: InputDecoration(labelText: 'Staff Number', hintText: 'enter staff number'),
),
Solution
can you confirm you are importing:
import 'package:flutter/services.dart';
at the start of your file?
Also, i think here is the answer to your question:
How to use InputFormatter on Flutter TextField?
"In the services library you will find the TextInputFormatter abstract class (this means that you have to import package:flutter/services.dart)."
Answered By - miguelik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.