Skip to content

Commit

Permalink
add example to WindowMainStateListener
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian-Samoticha committed Aug 15, 2023
1 parent 47e6974 commit 7b9b1b6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/src/utils/window_main_state_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ import 'package:macos_ui/macos_ui.dart';
/// A common use-case for responding to such changes would be to mute the colors
/// of certain primary UI elements when the window is no longer in focus, which
/// is something native macOS applications do out of the box.
///
/// Example using [StreamBuilder]:
///
/// ```dart
/// StreamBuilder(
/// stream: WindowMainStateListener.instance.onChangedStream,
/// builder: (context, _) {
/// final bool isMainWindow
/// = WindowMainStateListener.instance.isMainWindow;
///
/// return SomeWidget(
/// isMainWindow: isMainWindow,
/// child: ...
/// );
/// },
/// );
/// ```
class WindowMainStateListener {
/// A shared instance of [WindowMainStateListener].
static final instance = WindowMainStateListener();
Expand Down

0 comments on commit 7b9b1b6

Please sign in to comment.