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 : // TODO Maybe passing a type makes more sense than passing a name 10 : // that has the benefit that the WidgetElement's name will change when the 11 : // class name changes 12 : // 13 : // This could be avoided alltogether by using annotations 14 : final List<Story> stories; 15 : 16 1 : WidgetElement({ 17 : required String name, 18 : required this.stories, 19 : bool isExpanded = false, 20 1 : }) : super( 21 : name: name, 22 : isExpanded: isExpanded, 23 : ) { 24 2 : for (final Story state in stories) { 25 1 : state.parent = this; 26 : } 27 : } 28 : 29 1 : @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 : }