title: Flutter Sqflite how to get data from table and pass it to provider
body: <p>In my app these is a localdb containing user data which i have parsed from API. My objective is to get these values from local table and use that values for state management using provider. I have created a model class for the table</p>
  <pre><code>class UserTable {
    int? id;
    String? accountDetails;
    String? accountId;
    String? childName;
    String? childGender;
    int? expiry;
    int? finalSequenceNo;
    int? packageIndex;
    String? parentName;
    String? productType;
    String? userId;
    int? age;
    int? dob;
    int? nextSyncTime;
    String? productSubType;
    String? validTill;
    int? latestUpdatePkgSeqNo;
    int? guidedTour;
    UserTable(
        {this.id,
        this.accountDetails,
        this.accountId,
        this.childName,
        this.childGender,
        this.expiry,
        this.finalSequenceNo,
        this.packageIndex,
        this.parentName,
        this.productType,
        this.userId,
        this.age,
        this.dob,
        this.nextSyncTime,
        this.productSubType,
        this.validTill,
        this.latestUpdatePkgSeqNo,
        this.guidedTour,
        });
    Map&lt;String, dynamic&gt; toMap() {
      var map = &lt;String, dynamic&gt;{
        DatabaseHelper.USER_TABLE_ID: id,
        DatabaseHelper.ACCOUNT_DETAILS: accountDetails,
        DatabaseHelper.ACCOUNT_ID: accountId,
        DatabaseHelper.USER_CHILD_NAME: childName,
        DatabaseHelper.USER_CHILD_GENDER: childGender,
        DatabaseHelper.EXPIRY: expiry,
        DatabaseHelper.FINAL_SEQ_NO: finalSequenceNo,
        DatabaseHelper.PACKAGE_INDEX: packageIndex,
        DatabaseHelper.PARENT_NAME: parentName,
        DatabaseHelper.PRODUCT_TYPE: productType,
        DatabaseHelper.USER_ID: userId,
        DatabaseHelper.AGE: age,
        DatabaseHelper.DOB: dob,
        DatabaseHelper.NEXT_SYNC_TIME: nextSyncTime,
        DatabaseHelper.PRODUCT_SUB_TYPE: productSubType,
        DatabaseHelper.VALID_TILL: validTill,
        DatabaseHelper.LATEST_UPDATED_PKG_SEQ_NO: latestUpdatePkgSeqNo,
        DatabaseHelper.GUIDED_TOUR: guidedTour,
      };
      if (id != null) {
        map[DatabaseHelper.USER_TABLE_ID] = id;
      }
      return map;
    }
  
    UserTable.fromMap(Map&lt;String, dynamic&gt; map) {
      id = map[DatabaseHelper.USER_TABLE_ID];
      accountDetails = map[DatabaseHelper.ACCOUNT_DETAILS];
      accountId = map[DatabaseHelper.ACCOUNT_ID];
      childName = map[DatabaseHelper.USER_CHILD_NAME];
      childGender = map[DatabaseHelper.USER_CHILD_GENDER];
      expiry = map[DatabaseHelper.EXPIRY];
      finalSequenceNo = map[DatabaseHelper.FINAL_SEQ_NO];
      packageIndex = map[DatabaseHelper.PACKAGE_INDEX];
      parentName = map[DatabaseHelper.PARENT_NAME];
      productType = map[DatabaseHelper.PRODUCT_TYPE];
      userId = map[DatabaseHelper.USER_ID];
      age = map[DatabaseHelper.AGE];
      dob = map[DatabaseHelper.DOB];
      nextSyncTime = map[DatabaseHelper.NEXT_SYNC_TIME];
      productSubType = map[DatabaseHelper.PRODUCT_SUB_TYPE];
      validTill = map[DatabaseHelper.VALID_TILL];
      latestUpdatePkgSeqNo = map[DatabaseHelper.LATEST_UPDATED_PKG_SEQ_NO];
      guidedTour = map[DatabaseHelper.GUIDED_TOUR];
    }
  }
  </code></pre>
  <p>How can I retrieve data from localdb , so that I can use that data for statemanagement. Below is how now i'm retrieving data.</p>
  <pre><code>Future&lt;List&lt;UserTable&gt;&gt; getAllUserData() async {
      final db = await this.database;
      final List&lt;Map&lt;String, dynamic&gt;&gt; map =
          await db!.rawQuery(&quot;SELECT * FROM  $TABLE_USER&quot;);
          List&lt;UserTable&gt; list = map.isNotEmpty?map.map((e) =&gt; UserTable.fromMap(e)).toList():[];
          return list;
  </code></pre>
  <p>How can i achieve this? please suggest any workarounds</p>