text
stringlengths
1
372
<topic_start>
design to the strengths of each form factor
beyond screen size, you should also spend time
considering the unique strengths and weaknesses
of different form factors. it isn’t always ideal
for your multiplatform app to offer identical
functionality everywhere. consider whether it makes
sense to focus on specific capabilities,
or even remove certain features, on some device categories.
for example, mobile devices are portable and have cameras,
but they aren’t well suited for detailed creative work.
with this in mind, you might focus more on capturing content
and tagging it with location data for a mobile UI,
but focus on organizing or manipulating that content
for a tablet or desktop UI.
another example is leveraging the web’s extremely low barrier
for sharing. if you’re deploying a web app,
decide which deep links to support,
and design your navigation routes with those in mind.
the key takeaway here is to think about what each
platform does best and see if there are unique capabilities
you can leverage.
<topic_end>
<topic_start>
use desktop build targets for rapid testing
one of the most effective ways to test adaptive
interfaces is to take advantage of the desktop build targets.
when running on a desktop, you can easily resize the window
while the app is running to preview various screen sizes.
this, combined with hot reload, can greatly accelerate the
development of a responsive UI.
<topic_end>
<topic_start>
solve touch first
building a great touch UI can often be more difficult
than a traditional desktop UI due, in part,
to the lack of input accelerators like right-click,
scroll wheel, or keyboard shortcuts.
one way to approach this challenge is to focus initially
on a great touch-oriented UI. you can still do most of
your testing using the desktop target for its iteration speed.
but, remember to switch frequently to a mobile device to
verify that everything feels right.
after you have the touch interface polished, you can tweak
the visual density for mouse users, and then layer on all
the additional inputs. approach these other inputs as
accelerator—alternatives that make a task faster.
the important thing to consider is what a user expects
when using a particular input device,
and work to reflect that in your app.
<topic_end>
<topic_start>
input
of course, it isn’t enough to just adapt how your app looks,
you also have to support varying user inputs.
the mouse and keyboard introduce input types beyond those
found on a touch device—like scroll wheel, right-click,
hover interactions, tab traversal, and keyboard shortcuts.
<topic_end>
<topic_start>
scroll wheel
scrolling widgets like ScrollView or ListView
support the scroll wheel by default, and because
almost every scrollable custom widget is built
using one of these, it works with them as well.
if you need to implement custom scroll behavior,
you can use the listener widget, which lets you
customize how your UI reacts to the scroll wheel.
<code_start>
return listener(
onPointerSignal: (event) {
if (event is PointerScrollEvent) print(event.scrollDelta.dy);
},
child: ListView(),
);
<code_end>
<topic_end>
<topic_start>
tab traversal and focus interactions
users with physical keyboards expect that they can use
the tab key to quickly navigate your application,
and users with motor or vision differences often rely
completely on keyboard navigation.
there are two considerations for tab interactions:
how focus moves from widget to widget, known as traversal,
and the visual highlight shown when a widget is focused.
most built-in components, like buttons and text fields,
support traversal and highlights by default.
if you have your own widget that you want included in
traversal, you can use the FocusableActionDetector widget
to create your own controls. it combines the functionality
of actions, shortcuts, MouseRegion, and
focus widgets to create a detector that defines actions
and key bindings, and provides callbacks for handling focus
and hover highlights.
<code_start>
class _BasicActionDetectorState extends State<BasicActionDetector> {
bool _hasFocus = false;
@override
widget build(BuildContext context) {