setup method

void setup(
  1. String _method,
  2. SellonMethod sellonMethod,
  3. Parameter _parameter
)

Implementation

void setup(String _method, SellonMethod sellonMethod, Parameter _parameter) {
  // this._scrollController.removeListener(() { });
  this._scrollController?.addListener(() {
    // print("page ${this._currentPage}");
    if (_initialHeight == 0) {
      _initialHeight = _scrollController?.position.maxScrollExtent;
    }
    double requestPosition = this._scrollController!.position.maxScrollExtent -
        (_initialHeight! * 0.75);

    if (!this.isReverse) {
      if (this._scrollController!.position.pixels > 0) {
        if (_isLoading) {
          // print("here loading true");
          if (this._scrollController!.position.pixels > requestPosition) {
            String valuetype = "";
            _parameter.set("type", valuetype);

            _parameter.set("page", "${this._currentPage}");
            _parameter.set("page_size", this._perPage.toString());


            // onPaginationLoading(true);

            // if (_parameter.data.isNotEmpty) {
            // if(!this._stopScroll){
              if (this._total != 0) {
                // if (!this._isRefresh){
                _isLoading = false;

                // var api =
                if (_api is ApiSellon){
                  ApiSellon api = ApiSellon(this._api!.context);
                  api.execute(_method, sellonMethod, _parameter,
                          (response) {
                        //this.setCurrentPage(currentPages);

                        // onPaginationLoading(false);

                        Success success = new Success(this._api!, response.data());
                        this._isLoading = true;
                        this._onSuccessPaginator!(success);
                      });
                  api.setCompleteListener(() {
                    // onPaginationLoading(false);
                  });
                }else{
                  ApiGameSellon api = ApiGameSellon(this._api!.context);
                  api.execute(_method, _parameter,
                          (response) {
                        //this.setCurrentPage(currentPages);

                        // onPaginationLoading(false);

                        Success success = new Success(this._api!, response.data());
                        this._isLoading = true;
                        this._onSuccessPaginator!(success);
                      });
                  api.setCompleteListener(() {
                    // onPaginationLoading(false);
                  });
                }

                // }

              }
            // }
            // }
          }
        }
      } else {
        // _parameter.data.clear();
      }
    } else {
      // print("here loading lain true");
      if (this._scrollController!.position.pixels <= 0 && _isLoading) {
        _isLoading = false;
        _parameter.set("page", "${this._currentPage}");
        _parameter.set("page_size", this._perPage.toString());

        // onPaginationLoading!(true);

        // if(!this._stopScroll){
          if (this._total != 0) {
            if (_api is ApiSellon){
              ApiSellon api = ApiSellon(this._api!.context);
              api.execute(_method, sellonMethod, _parameter,
                      (response) {
                    //this.setCurrentPage(currentPages);

                    // onPaginationLoading!(false);

                    Success success = new Success(this._api!, response.data());
                    _isLoading = true;
                    this._onSuccessPaginator!(success);
                  });
              api.setCompleteListener(() {
                // onPaginationLoading!(false);
              });
            }else{
              ApiGameSellon api = ApiGameSellon(this._api!.context);
              api.execute(_method, _parameter,
                      (response) {
                    //this.setCurrentPage(currentPages);

                    // onPaginationLoading!(false);

                    Success success = new Success(this._api!, response.data());
                    _isLoading = true;
                    this._onSuccessPaginator!(success);
                  });
              api.setCompleteListener(() {
                // onPaginationLoading!(false);
              });
            }

          }
        // }
      }
    }
  });
}