How can I put a specific keyboard type to an autocomplete flutter?

How can I modify the input keyboard that comes out for an autocomplete from alphanumeric to numeric only?

Upvotes: 0

Views: 375

Answers (1)

MohitJadav
MohitJadav

Reputation: 954

TextFormField(
  controller: _controller,
  keyboardType: TextInputType.number,
  inputFormatters: <TextInputFormatter>[
   // for below version 2 use this
 FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), 
// for version 2 and greater youcan also use this
 FilteringTextInputFormatter.digitsOnly

  ],
  decoration: InputDecoration(
    labelText: "whatever you want",
    hintText: "whatever you want",
    icon: Icon(Icons.phone_iphone)
  )
)

use keyboardType: TextInputType.number,

Upvotes: 1

Related Questions