YaruWindowTitleBar class
A window title bar.
YaruWindowTitleBar
is a replacement for the native window title bar, that
allows inserting arbitrary Flutter widgets. It provides the same functionality
as the native window title bar, including window controls for minimizing,
maximizing, restoring, and closing the window, as well as a context menu,
and double-click-to-maximize and drag-to-move functionality.
Initialization
YaruWindowTitleBar
must be initialized on application startup. This
ensures that the native window title bar is hidden and the window content
area is configured as appropriate for the underlying platform.
Future<void> main() async {
await YaruWindowTitleBar.ensureInitialized();
runApp(...);
}
Usage
YaruWindowTitleBar
is typically used in place of AppBar
in Scaffold
.
Scaffold(
appBar: const YaruWindowTitleBar(
title: Text('YaruWindowTitleBar'),
),
body: ...
)
Modal barrier
When YaruWindowTitleBar
is placed inside a page route, it is not possible
to interact with the window title bar while a modal dialog is open because
the modal barrier is placed on top of the window title bar.
The issue can be avoided either by using YaruDialogTitleBar that allows dragging the window from the dialog title bar, or by using MaterialApp.builder to place the window title bar outside of the page route.
MaterialApp(
builder: (context, child) => Scaffold(
appBar: const YaruWindowTitleBar(
title: Text('YaruWindowTitleBar'),
),
body: child,
),
home: ...
)
Home | Builder |
---|---|
Debug banner
The debug banner
shown by MaterialApp
by default in debug mode does not fit well with an
in-scene window title bar. Therefore, when using YaruWindowTitleBar
, it is
recommended to turn off the built-in debug banner by setting debugShowCheckedModeBanner
to false
in MaterialApp
. Optionally, CheckedModeBanner
can be used to display the same debug banner in the content area instead so
that it does not overlap with the window title bar.
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: YaruWindowTitleBar(),
body: CheckedModeBanner(
child: ...
),
),
)
MaterialApp |
CheckedModeBanner |
---|---|
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- YaruWindowTitleBar
- Implemented types
- Implementers
Constructors
-
YaruWindowTitleBar({Key? key, Widget? leading, Widget? title, List<
Widget> ? actions, bool? centerTitle, double? titleSpacing, Color? foregroundColor, Color? backgroundColor, ShapeBorder? shape, BorderSide? border, YaruTitleBarStyle? style, bool? isActive, bool? isClosable, bool? isDraggable, bool? isMaximizable, bool? isMinimizable, bool? isRestorable, FutureOr<void> onClose(BuildContext)? = YaruWindow.close, FutureOr<void> onDrag(BuildContext)? = YaruWindow.drag, FutureOr<void> onMaximize(BuildContext)? = YaruWindow.maximize, FutureOr<void> onMinimize(BuildContext)? = YaruWindow.minimize, FutureOr<void> onRestore(BuildContext)? = YaruWindow.restore, FutureOr<void> onShowMenu(BuildContext)? = YaruWindow.showMenu, Object? heroTag = _kYaruTitleBarHeroTag, YaruWindowControlPlatform? platform, EdgeInsetsGeometry? buttonPadding, double? buttonSpacing}) -
const
Properties
-
actions
→ List<
Widget> ? -
Widgets to display after the title widget.
final
- backgroundColor → Color?
-
The background color.
final
- border → BorderSide?
-
The border.
final
-
final
-
final
- centerTitle → bool?
-
Whether the title should be centered.
final
- foregroundColor → Color?
-
The foreground color.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- heroTag → Object?
-
The tag to use for the Hero wrapping the window controls.
final
- isActive → bool?
-
Whether the title bar visualized as active.
final
- isClosable → bool?
-
Whether the title bar shows a close button.
final
- isDraggable → bool?
-
Whether the title bar can be dragged to move the window.
final
- isMaximizable → bool?
-
Whether the title bar shows a maximize button.
final
- isMinimizable → bool?
-
Whether the title bar shows a minimize button.
final
- isRestorable → bool?
-
Whether the title bar shows a restore button.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- leading → Widget?
-
A widget to display before the title widget.
final
-
onClose
→ FutureOr<
void> Function(BuildContext)? -
Called when the close button is pressed.
final
-
onDrag
→ FutureOr<
void> Function(BuildContext)? -
Called when the title bar is dragged to move the window.
final
-
onMaximize
→ FutureOr<
void> Function(BuildContext)? -
Called when the maximize button is pressed or the title bar is
double-clicked while the window is not maximized.
final
-
onMinimize
→ FutureOr<
void> Function(BuildContext)? -
Called when the minimize button is pressed.
final
-
onRestore
→ FutureOr<
void> Function(BuildContext)? -
Called when the restore button is pressed or the title bar is
double-clicked while the window is maximized.
final
-
onShowMenu
→ FutureOr<
void> Function(BuildContext)? -
Called when the secondary mouse button is pressed.
final
- platform → YaruWindowControlPlatform?
-
final
- preferredSize → Size
-
The size this widget would prefer if it were otherwise unconstrained.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → ShapeBorder?
-
The shape.
final
- style → YaruTitleBarStyle?
-
The style.
final
- title → Widget?
-
The primary title widget.
final
- titleSpacing → double?
-
Spacing around the title.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
ensureInitialized(
) → Future< void>