| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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.iconPackageName,
- this.iconActivityName,
- });
- final String packageName;
- final String activityName;
- final String label;
- /// Optional app whose icon should be used for this Home button. Only pinned
- /// apps use this; slot assignments leave both fields null.
- final String? iconPackageName;
- final String? iconActivityName;
- bool get hasCustomIcon =>
- (iconPackageName?.isNotEmpty ?? false) &&
- (iconActivityName?.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?) ?? '',
- iconPackageName: map['iconPackage'] as String?,
- iconActivityName: map['iconActivity'] as String?,
- );
- }
- Map<String, Object?> toMap() {
- return {
- 'package': packageName,
- 'activity': activityName,
- 'label': label,
- if (hasCustomIcon) 'iconPackage': iconPackageName,
- if (hasCustomIcon) 'iconActivity': iconActivityName,
- };
- }
- @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;
- }
|