Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
39 changed files
with
1,918 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,72 @@ | ||
# Examples | ||
# How to use? | ||
|
||
To add an icon to your app, simply use the [`TrayIconWidget`](../lib/src/widgets.dart). | ||
|
||
```dart | ||
import 'package:betrayal/betrayal.dart'; | ||
import 'package:flutter/material.dart'; | ||
void main() { | ||
runApp(const MyApp()); | ||
} | ||
class MyApp extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) => MaterialApp( | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text("Look at the system tray 👀") | ||
), | ||
body: Center( | ||
child: TrayIconWidget( | ||
winIcon: WinIcon.application, | ||
tooltip: "Here I am!" | ||
child: FlutterLogo() | ||
) | ||
) | ||
) | ||
); | ||
} | ||
``` | ||
|
||
Check out the [Widgets Api](widget_api/lib/main.dart) example to learn more about this approach. | ||
|
||
## Ok, but I want to work with `TrayIcon`s directly, please! | ||
|
||
Sure, you can use the [imperative api](../lib/src/imperative.dart) to create and control `TrayIcon`s directly. | ||
|
||
```dart | ||
final icon = TrayIcon(); | ||
await icon.setTooltip("🎭"); | ||
await icon.setImage(asset: "assets/dart.ico")); | ||
await icon.show(); | ||
``` | ||
|
||
Just make sure to dispose of it and free its resources once you're done. | ||
|
||
```dart | ||
icon.dispose(); | ||
``` | ||
|
||
If you don't feel like managing an icon, you can still use a `TrayIconWidget` and get its underlying `TrayIcon` by calling `TrayIcon.of(context)`. | ||
|
||
```dart | ||
@override | ||
Widget build(BuildContext context) { | ||
return TrayIconWidget( | ||
child: | ||
// ............. | ||
Builder( | ||
builder: (BuildContext context) { | ||
// The BuildContext must be from a child of `TrayIconWidget`, | ||
// otherwise the icon may not be found. | ||
return IconButton( | ||
onPressed: () => TrayIcon.of(context).setTooltip("🙇♂️"), | ||
icon: Icon(Icons.add) | ||
); | ||
} | ||
) | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: c860cba910319332564e1e9d470a17074c1f2dfd | ||
channel: stable | ||
|
||
project_type: app |
Oops, something went wrong.