flutterdartbarcode-scanner

Flutter : external barcode scanner continuous


I am developing a flutter application with below process

  1. scan number (external Bluetooth barcode scanner)
  2. upload barcode data
  3. repeat 1,2 step c

I could able to scan and upload the first data. then I cleared the text. but i could not place the cursor at the _text controller.

I dont want to press the text field every time before scan the textfield.

TextField(
                controller: _text,
                  textInputAction: TextInputAction.go,
                onSubmitted: (value) {
                  print(submit online using function");
                  _text.clear();
                  _text.selection= TextSelection.collapsed(offset: -1);

                },
                decoration: const InputDecoration(
                  icon: Icon(Icons.person),
                  hintText: 'Enter ID',
                  labelText: 'Enter ID',
                ),
                autofocus: true,
                keyboardType: TextInputType.number,
                inputFormatters: <TextInputFormatter>[
                  WhitelistingTextInputFormatter.digitsOnly
                ],
              ),

Solution

  •    TextFormField(
              enabled: true,
              autofocus: true,
              autocorrect: false,
              textInputAction: TextInputAction.done,
              keyboardType: TextInputType.text,
              focusNode: focusBarCode,
              onFieldSubmitted: (val) {
                print(val); // the scan value
                //process the val
                barCodecontroller.text =""; // set to blank again
                focusBarCode.requestFocus();//set focus again, so u can 
                                            //scan again
           `enter code here`},
           controller: barCodecontroller,
        ),