title: Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 0
body: <p>this method running always. I checked with API. If API value change I delete my database and insert again. Is that right way to use like this scenario? (can use streamWidget or FutureWidget? If can How? )</p>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception:
    RangeError (index): Invalid value: Valid value range is empty: 0</p>
  </blockquote>
  
  <pre><code> checkQuick(String url, String token) async {
      result =
          (await HelperDatabase1().displayGetUserPreference()).elementAt(0)?.data;
      final response = await http.get(
        '$url/nativeapi/v1.0/User/GetUserPreference',
        headers: {'Authorization': 'Bearer $token'},
      );
      final jsonResponse = json.decode(response.body);
      GetUserPreference model = GetUserPreference.fromJson(jsonResponse);
      var data = GetUserPreference(data: model.data);
  
      if (result != data.data) {
        await HelperDatabase1().deleteGetUserPreference();
        await HelperDatabase1().storeGetUserPreference(url, token);
      }
    }
  </code></pre>