text
stringlengths
1
372
const spacer(),
FocusTraversalOrder(
order: const NumericFocusOrder(3),
child: TextButton(
child: const Text('THREE'),
onPressed: () {},
),
),
const spacer(),
],
),
);
}
}
<code_end>
<topic_end>
<topic_start>
FocusTraversalPolicy
the FocusTraversalPolicy is the object that determines which widget is next,
given a request and the current focus node. the requests (member functions) are
things like findFirstFocus, findLastFocus, next, previous, and
inDirection.
FocusTraversalPolicy is the abstract base class for concrete policies, like
ReadingOrderTraversalPolicy, OrderedTraversalPolicy and the
DirectionalFocusTraversalPolicyMixin classes.
in order to use a FocusTraversalPolicy, you give one to a
FocusTraversalGroup, which determines the widget subtree in which the policy
will be effective. the member functions of the class are rarely called directly:
they are meant to be used by the focus system.
<topic_end>
<topic_start>
the focus manager
the FocusManager maintains the current primary focus for the system. it
only has a few pieces of API that are useful to users of the focus system. one
is the FocusManager.instance.primaryFocus property, which contains the
currently focused focus node and is also accessible from the global
primaryFocus field.
other useful properties are FocusManager.instance.highlightMode and
FocusManager.instance.highlightStrategy. these are used by widgets that need
to switch between a “touch” mode and a “traditional” (mouse and keyboard) mode
for their focus highlights. when a user is using touch to navigate, the focus
highlight is usually hidden, and when they switch to a mouse or keyboard, the
focus highlight needs to be shown again so they know what is focused. the
hightlightStrategy tells the focus manager how to interpret changes in the
usage mode of the device: it can either automatically switch between the two
based on the most recent input events, or it can be locked in touch or
traditional modes. the provided widgets in flutter already know how to use this
information, so you only need it if you’re writing your own controls from
scratch. you can use addHighlightModeListener callback to listen for changes
in the highlight mode.
<topic_end>
<topic_start>
adding assets and images
flutter apps can include both code and assets
(sometimes called resources). an asset is a file
that is bundled and deployed with your app,
and is accessible at runtime. common types of assets include
static data (for example, JSON files),
configuration files, icons, and images
(jpeg, WebP, GIF, animated WebP/GIF, PNG, BMP, and WBMP).
<topic_end>
<topic_start>
specifying assets
flutter uses the pubspec.yaml file,
located at the root of your project,
to identify assets required by an app.
here is an example:
to include all assets under a directory,
specify the directory name with the / character at the end:
info note
only files located directly in the directory are included.
resolution-aware asset image variants are the only exception.
to add files located in subdirectories, create an entry per directory.
<topic_end>
<topic_start>
asset bundling
the assets subsection of the flutter section
specifies files that should be included with the app.
each asset is identified by an explicit path
(relative to the pubspec.yaml file) where the asset
file is located. the order in which the assets are
declared doesn’t matter. the actual directory name used
(assets in first example or directory in the above
example) doesn’t matter.
during a build, flutter places assets into a special
archive called the asset bundle that apps read
from at runtime.
<topic_end>
<topic_start>
loading assets
your app can access its assets through an
AssetBundle object.
the two main methods on an asset bundle allow you to load a
string/text asset (loadstring()) or an image/binary asset (load())
out of the bundle, given a logical key. the logical key maps to the path
to the asset specified in the pubspec.yaml file at build time.
<topic_end>
<topic_start>
loading text assets
each flutter app has a rootBundle