content: import 'dart:developer';
  
  import 'package:flutter/foundation.dart';
  import 'package:get/get.dart';
  import 'package:tec/constant/api_constant.dart';
  import 'package:tec/models/article_model.dart';
  import 'package:tec/services/dio_service.dart';
  
  class ListArticleController extends GetxController {
    RxList<ArticleModel> articleList = RxList();
    RxBool loading = false.obs;
  
    @override
    onInit() {
      super.onInit();
      getList();
    }
  
    getList() async {
      loading.value = true;
      // ignore: todo
      //TODO get userid from getStorage ApiConstant.getArticleList+userid
      var response = await DioService().getMethod(ApiUrlConstant.getArticleList);
  
      if (response.statusCode == 200) {
        response.data.forEach((element) {
          articleList.add(ArticleModel.fromJson(element));
        });
        loading.value = false;
      }
    }
  
    getArticleListWithTagsId(String id) async {
      articleList.clear();
      loading.value = true;
      // ignore: todo
      //TODO get userid from getStorage ApiConstant.getArticleList+userid
  
      final queryParam = {
        'command': 'get_articles_with_tag_id',
        'tag_id': id,
        'user_id': ''
      };
  
      final uri = Uri.https(ApiUrlConstant.baseUrl, 'article/get.php?', queryParam);
   
      var response = await DioService().getMethod(uri.toString());
  
      if (response.statusCode == 200) {
        response.data.forEach((element) {
          articleList.add(ArticleModel.fromJson(element));
        });
        loading.value = false;
      }
    }
  }
  