| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import 'package:flutter/foundation.dart';
- /// A persisted app choice for one shortcut slot.
- @immutable
- class SlotAssignment {
- const SlotAssignment({
- required this.packageName,
- required this.activityName,
- required this.label,
- this.iconAsset,
- });
- final String packageName;
- final String activityName;
- final String label;
- /// Optional stylized SVG icon for this Home button. Null means the pinned
- /// app's own icon (or the generic fallback for fixed slots).
- final String? iconAsset;
- bool get hasCustomIcon => iconAsset?.isNotEmpty ?? false;
- factory SlotAssignment.fromMap(Map<dynamic, dynamic> map) {
- return SlotAssignment(
- packageName: (map['package'] as String?) ?? '',
- activityName: (map['activity'] as String?) ?? '',
- label: (map['label'] as String?) ?? '',
- iconAsset: map['iconAsset'] as String?,
- );
- }
- Map<String, Object?> toMap() {
- return {
- 'package': packageName,
- 'activity': activityName,
- 'label': label,
- if (hasCustomIcon) 'iconAsset': iconAsset,
- };
- }
- @override
- bool operator ==(Object other) {
- return other is SlotAssignment &&
- other.packageName == packageName &&
- other.activityName == activityName;
- }
- @override
- int get hashCode => Object.hash(packageName, activityName);
- @override
- String toString() => label.isEmpty ? packageName : label;
- }
|