Line data Source code
1 : import 'package:collection/collection.dart'; 2 : 3 : import 'package:widgetbook/src/models/models.dart'; 4 : 5 : class OrganizerState { 6 : final List<Category> allCategories; 7 : final List<Category> filteredCategories; 8 : final String searchTerm; 9 : 10 1 : factory OrganizerState.unfiltered({ 11 : required List<Category> categories, 12 : }) { 13 1 : return OrganizerState( 14 : allCategories: categories, 15 : filteredCategories: categories, 16 : searchTerm: '', 17 : ); 18 : } 19 : 20 1 : OrganizerState({ 21 : required this.allCategories, 22 : required this.filteredCategories, 23 : required this.searchTerm, 24 : }); 25 : 26 1 : @override 27 : bool operator ==(Object other) { 28 : if (identical(this, other)) return true; 29 1 : final listEquals = const DeepCollectionEquality().equals; 30 : 31 1 : return other is OrganizerState && 32 2 : listEquals(other.allCategories, allCategories) && 33 2 : listEquals(other.filteredCategories, filteredCategories) && 34 3 : other.searchTerm == searchTerm; 35 : } 36 : 37 0 : @override 38 : int get hashCode => 39 0 : allCategories.hashCode ^ 40 0 : filteredCategories.hashCode ^ 41 0 : searchTerm.hashCode; 42 : }