Untitled
unknown
dart
2 years ago
1.4 kB
1
Indexable
Never
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:iketfaa_delivery/App/Common/Services/AuthenticationService/Core/manager.dart'; import 'package:iketfaa_delivery/App/Freelance/Models/Main/UserPostItem.dart'; class MyProfileController extends GetxController with GetSingleTickerProviderStateMixin { final AuthenticationManager authManager = Get.find(); late Rx<TabController> tabController; late RxInt tabIndex = 0.obs; RxBool isLoading = false.obs; RxBool notCached = true.obs; RxInt postsPageIndex = 2.obs; RxList<UserPostItem> userPosts = <UserPostItem>[].obs; @override Future<void> onInit() async { tabController = TabController(vsync: this, length: 2).obs; userPosts.value = await authManager.api.getUserFirst12Posts(false).then( (value) => authManager.api .getUserFirst12Posts(true) .then((value) => userPosts.value = value)); super.onInit(); } @override Future<void> onReady() async { print(userPosts.length); super.onInit(); } Future getAllNewPost(String id) async { notCached = true.obs; postsPageIndex.value = 2; authManager.appUser.update((val) { val!.accountInfoCounters!.posts = (val.accountInfoCounters!.posts! + 1); }); userPosts.value = await authManager.api.getUserFirst12Posts(true); } }