diff --git a/app/lib/selections/file.dart b/app/lib/selections/file.dart index c22fa438f6ed..5841452e65b6 100644 --- a/app/lib/selections/file.dart +++ b/app/lib/selections/file.dart @@ -1,7 +1,7 @@ part of 'selection.dart'; -class FileSelection extends Selection { - FileSelection() : super([null]); +class FileSelection extends Selection { + FileSelection(CurrentIndexCubit cubit) : super([cubit]); @override IconGetter get icon => PhosphorIcons.wrench; @@ -15,7 +15,7 @@ class FileSelection extends Selection { @override List buildProperties(BuildContext context) { - final cubit = context.read(); + final cubit = selected.first; final currentIndex = cubit.state; return [ ...super.buildProperties(context), diff --git a/app/lib/selections/selection.dart b/app/lib/selections/selection.dart index 562d4ad5650d..86573d5fa859 100644 --- a/app/lib/selections/selection.dart +++ b/app/lib/selections/selection.dart @@ -65,8 +65,8 @@ abstract class Selection { if (selected is Area) { return AreaSelection([selected]) as Selection; } - if (selected == null) { - return FileSelection() as Selection; + if (selected is CurrentIndexCubit) { + return FileSelection(selected) as Selection; } throw UnsupportedError('Unsupported selection type: $T'); } diff --git a/app/lib/views/edit.dart b/app/lib/views/edit.dart index 5b37119c7c03..d0b1ee267b76 100644 --- a/app/lib/views/edit.dart +++ b/app/lib/views/edit.dart @@ -377,11 +377,11 @@ class _EditToolbarState extends State { tooltip: AppLocalizations.of(context).tools, selectedIcon: const PhosphorIcon(PhosphorIconsFill.wrench), isSelected: currentIndex.selection?.selected - .any((element) => element is UtilitiesState) ?? + .any((element) => element is CurrentIndexCubit) ?? false, onPressed: () { final cubit = context.read(); - cubit.changeSelection(null); + cubit.changeSelection(cubit); }, ), if (windowState.fullScreen && diff --git a/app/lib/visualizer/icon.dart b/app/lib/visualizer/icon.dart index f148bad30731..253984c570bc 100644 --- a/app/lib/visualizer/icon.dart +++ b/app/lib/visualizer/icon.dart @@ -23,7 +23,7 @@ enum DisplayIcons { return recommended(tool).firstOrNull?.icon ?? PhosphorIcons.question; } - static List recommended(Object tool) { + static List recommended(Object? tool) { return switch (tool) { PenTool _ => [ DisplayIcons.pen,