1

I am building a POS system for desktop in flutter. I have used this package -> package to get product suggestions and barcode suggestions. It works fine when I search product by manuallay typing. and when I type manually barcode it also works fine. but when I scan the barcode using the barcode scanner it does not add the product in the list.

How can I detect the event in that form field or add product into list using barcode scanner ?

Image

CODE

 Expanded(
                                      child: TypeAheadField(
                                        textFieldConfiguration:
                                            TextFieldConfiguration(
                                                decoration: const InputDecoration(
                                                    label:
                                                        Text("Search Product"),
                                                    prefixIcon: Icon(
                                                        Icons.shopping_bag),
                                                    border:
                                                        OutlineInputBorder()),
                                                controller: _productController),
                                        suggestionsCallback: (pattern) async {
                                          return await POSServices
                                              .getProudctByNameOrBarcode(
                                                  pattern);
                                        },
                                        minCharsForSuggestions: 1,
                                        itemBuilder: (context, suggestion) {
                                          suggestion as Map;
                                          return ListTile(
                                            leading: const Icon(
                                              Icons.shopping_bag_outlined,
                                              color: Colors.blue,
                                            ),
                                            title: Text(
                                                suggestion['english_name']),
                                            subtitle: Text(
                                                "Rs. ${suggestion['sale_price']}"),
                                          );
                                        },
                                        onSuggestionSelected: (suggestion) {
                                          productData = suggestion as Map;
                                          
                              _productController.text =suggestion['english_name'].toString();
                 
                
               
       posBuilderController.getProductDetailsWithMultiplePrices(
                                                    suggestion['product_id'].toString()).then((data) {
//code 
});
                                        },
                                    
                                      ),
                                    ),

0 Answers0