import 'package:flutter_bloc/flutter_bloc.dart';

import '../models/category.dart';

class CategorySelection extends Cubit<List<dynamic>> {
  CategorySelection() : super([[], 'All']);

  void getCategorySelect(List<Category> listCategory, String categorySelected) {
    List<Category> categorySelectedList = [];

    if (categorySelected != '') {
      if (categorySelected == 'All') {
        categorySelectedList = listCategory;
      } else {
        for (var x in listCategory) {
          if (x.name == categorySelected) {
            categorySelectedList.add(x);
          }
        }
      }
    }
    emit([categorySelectedList, categorySelected]);
  }
}
