Reputation: 1121
I have need annoyed with the warning from the android studio
on me not using the defined variable
but in actual I have used it. What can be issue ? is something wrong with my coding pattern ?
class CategoryProvider with ChangeNotifier {
List<CategoryModel> _categories = [];
int _currenPage = 1;
int _lastPage = 1;
int _perPage = 1;
List<CategoryModel> getCategories() => [..._categories];
void setCategories(List<CategoryModel> _records) {
_categories = _records;
notifyListeners();
}
Future fetchCategories() async {
try {
ApiCall().getData(categoriesApi).then((data) {
if (data['status'] == 'success') {
_currenPage = data['collection']['current_page'];
In the above code, we can clearly see that the _current_page
is been defined
and used
in the fetchCategories
function. then why is android studio
crying
for the same?
Above is just an example and many more such variable
exist and I have issued warnings
for all.
Any suggestions on how to solve this ?
Upvotes: 0
Views: 163
Reputation: 1960
_currenPage = data['collection']['current_page'];
This means that you are declaring the _currenPage
variable you haven't used it anywhere.
you can use it like print(_currenPage)
or pass it in some function.
hopes it helps!
Upvotes: 1