text
stringlengths 1
474
|
|---|
static const double xsmall = 3;
|
static const double small = 4;
|
static const double medium = 5;
|
static const double large = 10;
|
static const double extraLarge = 20;
|
// etc
|
}
|
class Fonts {
|
static const String raleway = 'Raleway';
|
// etc
|
}
|
class TextStyles {
|
static const TextStyle raleway = TextStyle(
|
fontFamily: Fonts.raleway,
|
);
|
static TextStyle buttonText1 =
|
const TextStyle(fontWeight: FontWeight.bold, fontSize: 14);
|
static TextStyle buttonText2 =
|
const TextStyle(fontWeight: FontWeight.normal, fontSize: 11);
|
static TextStyle h1 =
|
const TextStyle(fontWeight: FontWeight.bold, fontSize: 22);
|
static TextStyle h2 =
|
const TextStyle(fontWeight: FontWeight.bold, fontSize: 16);
|
static TextStyle body1 = raleway.copyWith(color: const Color(0xFF42A5F5));
|
// etc
|
}<code_end>
|
These constants can then be used in place of hard-coded numeric values:
|
<code_start>return Padding(
|
padding: const EdgeInsets.all(Insets.small),
|
child: Text('Hello!', style: TextStyles.body1),
|
);<code_end>
|
Use Theme.of(context).platform for theming and
|
design choices, like what kind of switches to show
|
and general Cupertino/Material adaptions.With all views referencing the same shared-design system rules,
|
they tend to look better and more consistent.
|
Making a change or adjusting a value for a specific platform
|
can be done in a single place, instead of using an error-prone
|
search and replace. Using shared rules has the added benefit
|
of helping enforce consistency on the design side.Some common design system categories that can be represented
|
this way are:Like most rules, there are exceptions:
|
one-off values that are used nowhere else in the app.
|
There is little point in cluttering up the styling rules
|
with these values, but it’s worth considering if they
|
should be derived from an existing value (for example,
|
padding + 1.0). You should also watch for reuse or duplication
|
of the same semantic values. Those values should likely be
|
added to the global styling ruleset.<topic_end>
|
<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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.