setup method
Implementation
void setup(String _method, SellonMethod sellonMethod, Parameter _parameter) {
// this._scrollController.removeListener(() { });
if (this._parameterSet != null){
_parameter = this._parameterSet!;
}
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());
int ind = 0;
if(this._videoCommunitys != null){
this._videoCommunitys?.forEach((element) {
if (element.id != null){
_parameter.set("watched_video[$ind][community_id]", element.id!);
}
if (element.videoId != null){
_parameter.set("watched_video[$ind][video_id]", element.videoId!);
}
ind = ind + 1;
});
}
// onPaginationLoading(true);
// if (_parameter.data.isNotEmpty) {
// if(!this._stopScroll){
if (this._total != 0) {
// if (!this._isRefresh){
_isLoading = false;
// var api =
if (_api is Api){
Api api = Api();
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);
},urlFix: _urlFix,encrytion: _encryption);
api.setCompleteListener(() {
// onPaginationLoading(false);
});
}else if (_api is ApiSellon) {
ApiSellon api = ApiSellon();
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 Api){
Api api = Api();
api.execute(_method, sellonMethod, _parameter,
(response) {
//this.setCurrentPage(currentPages);
// onPaginationLoading!(false);
Success success = new Success(this._api!, response.data());
_isLoading = true;
this._onSuccessPaginator!(success);
},urlFix: _urlFix,encrytion: _encryption);
api.setCompleteListener(() {
// onPaginationLoading!(false);
});
}else if (_api is ApiSellon){
ApiSellon api = ApiSellon();
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);
});
}
}
// }
}
}
});
}