initialLoad method

void initialLoad()

========================================= load data at first (or refreshing scenarios)

Implementation

void initialLoad() async {
  if (!_isLoading) {
    _isLoading = true;

    /// change state of screen to LOADING
    screenType.value = KScreenType.LOADING;

    /// request data
    final result = await _model!.request(page: 1);

    if (result != null) {
      if (result.length > 0) {
        datasource.clear();
        datasource.addAll(result);
        currentPage.value = 1;
        screenType.value = KScreenType.LIST;
      } else {
        screenType.value = KScreenType.EMPTY;
      }
    } else {
      screenType.value = KScreenType.EMPTY;
    }

    /// reset state of loading
    _isLoading = false;
  }
}