Skip to content

Commit

Permalink
fix(example): show tray icon immediately. The user does not have to c…
Browse files Browse the repository at this point in the history
…hange their selection first
  • Loading branch information
benthillerkus committed Mar 31, 2022
1 parent ed3b9fe commit 7ad2993
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions example/edit_icon/lib/main.dart
Expand Up @@ -49,12 +49,24 @@ class MyData extends ElementSelectorData {
class _HomeScreenState extends State<HomeScreen> {
late final TrayIcon _icon = TrayIcon(const TrayIconData());

@override
void initState() {
super.initState();
_setTrayIcon(_delegate.elementAt(0));
}

@override
void dispose() {
_icon.dispose();
super.dispose();
}

void _setTrayIcon(MyData element) {
_icon.setTooltip(element.name ?? element.key.toString());
_icon.setIcon();
_icon.show();
}

final _delegate = ElementSelectorDelegate(initialItems: [
MyData(name: "A", builder: (_) => const FlutterLogo()),
MyData(name: "B", builder: (_) => const FlutterLogo()),
Expand All @@ -68,10 +80,7 @@ class _HomeScreenState extends State<HomeScreen> {
axis: Axis.vertical,
onSelectionChanged: (index) {
final element = _delegate.elementAt(index);

_icon.setTooltip(element.name ?? element.key.toString());
_icon.setIcon();
_icon.show();
_setTrayIcon(element);
},
addTooltip: "Add new Image",
delegate: _delegate,
Expand Down

0 comments on commit 7ad2993

Please sign in to comment.