'Flutter - Database(SQlite) getting locked while Showing data in listview using provider

Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction.

I recieved this error while showing data in screen. And it takes too much time for showing data. So I have to reduce time.

In Futurebuilder i Called method like this

future: Provider.of<AllMethodCallProvider>(context,listen: false).sendAllOfflineData(context, accessToken).
then((value) {Provider.of<StowDetailProvider>(context, listen: false).searchPOItem(accessToken:accessToken,po_id: widget.po_id!,selectedSiteId: widget.siteId!,poNumber:widget.searchPOText!,   searchVendorPartNumber:widget.vendorPartName!,vendorName:widget.vendorName!,itemStatus:widget.item_status!,
          context: context).then((value) {
        Provider.of<StowDetailProvider>(context,listen: false).isSubmitted = false;
      });
    }),

Also I used for loop for adding API data in list.

I tried await batch.commit(); But Not getting expected output.



Solution 1:[1]

The library import was not successful and you are not able to use your keyword. Have a look at the documentation on how to import. The most foolproof solution is to use absolute path to your library. eg.:

*** Settings ***    
Library    /absolute/path/JavaLibrary.java

try using current directory variable from system variables

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mperic