text stringlengths 1 474 |
|---|
);<code_end> |
This subtle attention to detail can make your app feel more |
comfortable on a given platform.<topic_end> |
<topic_start>Multi-select |
Dealing with multi-select within a list is another area |
with subtle differences across platforms: |
<code_start>static bool get isSpanSelectModifierDown => |
isKeyDown({LogicalKeyboardKey.shiftLeft, LogicalKeyboardKey.shiftRight});<code_end> |
To perform a platform-aware check for control or command, |
you can write something like this: |
<code_start>static bool get isMultiSelectModifierDown { |
bool isDown = false; |
if (Platform.isMacOS) { |
isDown = isKeyDown( |
{LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.metaRight}, |
); |
} else { |
isDown = isKeyDown( |
{LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.controlRight}, |
); |
} |
return isDown; |
}<code_end> |
A final consideration for keyboard users is the Select All action. |
If you have a large list of items of selectable items, |
many of your keyboard users will expect that they can use |
Control+A to select all the items.<topic_end> |
<topic_start>Touch devices |
On touch devices, multi-selection is typically simplified, |
with the expected behavior being similar to having the |
isMultiSelectModifier down on the desktop. |
You can select or deselect items using a single tap, |
and will usually have a button to Select All or |
Clear the current selection.How you handle multi-selection on different devices depends |
on your specific use cases, but the important thing is to |
make sure that you’re offering each platform the best |
interaction model possible.<topic_end> |
<topic_start>Selectable text |
A common expectation on the web (and to a lesser extent desktop) |
is that most visible text can be selected with the mouse cursor. |
When text is not selectable, |
users on the web tend to have an adverse reaction.Luckily, this is easy to support with the SelectableText widget: |
<code_start>return const SelectableText('Select me!');<code_end> |
To support rich text, then use TextSpan: |
<code_start>return const SelectableText.rich( |
TextSpan( |
children: [ |
TextSpan(text: 'Hello'), |
TextSpan(text: 'Bold', style: TextStyle(fontWeight: FontWeight.bold)), |
], |
), |
);<code_end> |
<topic_end> |
<topic_start>Title bars |
On modern desktop applications, it’s common to customize |
the title bar of your app window, adding a logo for |
stronger branding or contextual controls to help save |
vertical space in your main UI.This isn’t supported directly in Flutter, but you can use the |
bits_dojo package to disable the native title bars, |
and replace them with your own.This package lets you add whatever widgets you want to the |
TitleBar because it uses pure Flutter widgets under the hood. |
This makes it easy to adapt the title bar as you navigate |
to different sections of the app.<topic_end> |
<topic_start>Context menus and tooltips |
On desktop, there are several interactions that |
manifest as a widget shown in an overlay, |
but with differences in how they’re triggered, dismissed, |
and positioned:Context menu—Typically triggered by a right-click, |
a context menu is positioned close to the mouse, |
and is dismissed by clicking anywhere, |
selecting an option from the menu, or clicking outside it.Tooltip—Typically triggered by hovering for |
200-400ms over an interactive element, |
a tooltip is usually anchored to a widget |
(as opposed to the mouse position) and is dismissed |
when the mouse cursor leaves that widget.Popup panel (also known as flyout)—Similar to a tooltip, |
a popup panel is usually anchored to a widget. |
The main difference is that panels are most often |
shown on a tap event, and they usually don’t hide |
themselves when the cursor leaves. |
Instead, panels are typically dismissed by clicking |
outside the panel or by pressing a Close or Submit button.To show basic tooltips in Flutter, |
use the built-in Tooltip widget: |
<code_start>return const Tooltip( |
message: 'I am a Tooltip', |
child: Text('Hover over the text to show a tooltip.'), |
);<code_end> |
Flutter also provides built-in context menus when editing |
or selecting text.To show more advanced tooltips, popup panels, |
or create custom context menus, |
you either use one of the available packages, |
or build it yourself using a Stack or Overlay.Some available packages include:While these controls can be valuable for touch users as accelerators, |
they are essential for mouse users. These users expect |
to right-click things, edit content in place, |
and hover for more information. Failing to meet those expectations |
can lead to disappointed users, or at least, |
a feeling that something isn’t quite right.<topic_end> |
<topic_start>Horizontal button order |
On Windows, when presenting a row of buttons, |
the confirmation button is placed at the start of |
the row (left side). On all other platforms, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.