import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class FixProvider extends ChangeNotifier { List _fixModels = FixModel.initList(); List get fixModels => _fixModels; addFixModel(FixModel model) { _fixModels.insert(0, model); notifyListeners(); } List getFixModel(int index, BuildContext context) { final userProvider = Provider.of(context, listen: false); USER_ROLE role = userProvider.userInfoModel.role; List _doneModels = _fixModels.where((element) => element.type == FIX_ENUM.DONE).toList(); List _processingModels = _fixModels .where((element) => element.type == FIX_ENUM.PROCESSING) .toList(); List _handOutModels = _fixModels .where((element) => element.type == FIX_ENUM.HAND_OUT) .toList(); List _waitPickUpModels = _fixModels .where((element) => element.type == FIX_ENUM.WAIT_PICKUP) .toList(); switch (role) { case USER_ROLE.MANAGER: return [ _handOutModels, _waitPickUpModels, _processingModels, _doneModels, _fixModels, ][index]; break; default: return [ _waitPickUpModels, _processingModels, _doneModels, _fixModels, ][index]; break; } } }