Line data Source code
1 : import 'package:collection/collection.dart'; 2 : 3 : import 'package:widgetbook/src/models/organizers/expandable_organizer.dart'; 4 : import 'package:widgetbook/src/models/organizers/organizers.dart'; 5 : import 'package:widgetbook/src/models/organizers/story.dart'; 6 : 7 : /// 8 : class WidgetElement extends ExpandableOrganizer { 9 2 : WidgetElement({ 10 : required String name, 11 : required this.stories, 12 : bool isExpanded = false, 13 2 : }) : super( 14 : name: name, 15 : isExpanded: isExpanded, 16 : ) { 17 4 : for (final state in stories) { 18 2 : state.parent = this; 19 : } 20 : } 21 : 22 : // TODO Maybe passing a type makes more sense than passing a name 23 : // that has the benefit that the WidgetElement's name will change when the 24 : // class name changes 25 : // 26 : // This could be avoided alltogether by using annotations 27 : final List<Story> stories; 28 : 29 2 : @override 30 : bool operator ==(Object other) { 31 : if (identical(this, other)) return true; 32 1 : final listEquals = const DeepCollectionEquality().equals; 33 : 34 3 : return other is WidgetElement && listEquals(other.stories, stories); 35 : } 36 : 37 0 : @override 38 0 : int get hashCode => stories.hashCode; 39 : }