text stringlengths 1 372 |
|---|
and enhanced accessibility, to foundations for |
large screen layouts, and design tokens. |
warning warning |
as of the flutter 3.16 release, material 3 is |
enabled by default. for now, you can opt out |
of material 3 by setting the useMaterial3 property |
to false. but be aware that the useMaterial3 |
property and support for material 2 |
will eventually be deprecated according to |
flutter’s deprecation policy. |
for most flutter widgets, upgrading to material 3 |
is seamless. but some widgets couldn’t be |
updated—entirely new implementations were needed, |
such as NavigationBar. |
you must make these changes to your code manually. |
until your app is entirely updated, |
the UI might look or act a bit strange. |
you can find the entirely new material components by |
visiting the affected widgets page. |
explore the updated components, typography, color system, |
and elevation support with the |
interactive material 3 demo: |
<topic_end> |
<topic_start> |
more information |
to learn more about material design and flutter, |
check out: |
<topic_end> |
<topic_start> |
migrate to material 3 |
<topic_end> |
<topic_start> |
summary |
the material library has been updated to match the material 3 design spec. |
changes include new components and component themes, updated component visuals, |
and much more. many of these updates are seamless. you’ll see the new version |
of an affected widget when recompiling your app against the 3.16 (or later) |
release. but some manual work is also required to complete the migration. |
<topic_end> |
<topic_start> |
migration guide |
prior to the 3.16 release, you could opt in to the material 3 changes by |
setting the useMaterial3 flag to true. as of the flutter 3.16 release |
(november 2023), useMaterial3 is true by default. |
by the way, you can revert to material 2 behavior in your app by setting the |
useMaterial3 to false. however, this is just a temporary solution. the |
useMaterial3 flag and the material 2 implementation will eventually be |
removed as part of flutter’s deprecation policy. |
<topic_end> |
<topic_start> |
colors |
the default values for ThemeData.colorScheme are updated to match |
the material 3 design spec. |
the ColorScheme.fromSeed constructor generates a ColorScheme |
derived from the given seedColor. the colors generated by this |
constructor are designed to work well together and meet contrast |
requirements for accessibility in the material 3 design system. |
when updating to the 3.16 release, your UI might look a little strange |
without the correct ColorScheme. to fix this, migrate to the |
ColorScheme generated from the ColorScheme.fromSeed constructor. |
code before migration: |
code after migration: |
to generate a content-based dynamic color scheme, use the |
ColorScheme.fromImageProvider static method. for an example of generating a |
color scheme, check out the ColorScheme from a network image sample. |
changes to flutter material 3 include a new background color. |
ColorScheme.surfaceTint indicates an elevated widget. |
some widgets use different colors. |
to return your app’s UI to its previous behavior (which we don’t recommend): |
code before migration: |
code after migration: |
the ColorScheme.surfaceTint value indicates a component’s elevation in |
material 3. some widgets might use both surfaceTint and shadowColor to |
indicate elevation (for example, card and ElevatedButton) and others might |
only use surfaceTint to indicate elevation (such as AppBar). |
to return to the widget’s previous behavior, set, set colors.transparent |
to ColorScheme.surfaceTint in the theme. to differentiate a widget’s shadow |
from the content (when it has no shadow), set the ColorScheme.shadow color to |
the shadowColor property in the widget theme without a default shadow color. |
code before migration: |
code after migration: |
the ElevatedButton now styles itself with a new combination of colors. |
previously, when the useMaterial3 flag was set to false, ElevatedButton |
styled itself with ColorScheme.primary for the background and |
ColorScheme.onPrimary for the foreground. to achieve the same visuals, switch |
to the new FilledButton widget without the elevation changes or drop shadow. |
code before migration: |
code after migration: |
<topic_end> |
<topic_start> |
typography |
the default values for ThemeData.textTheme are updated to match the |
material 3 defaults. changes include updated font size, font weight, letter |
spacing, and line height. for more details, check out the TextTheme |
documentation. |
as shown in the following example, prior to the 3.16 release, when a text |
widget with a long string using TextTheme.bodyLarge in a constrained layout |
wrapped the text into two lines. however, the 3.16 release wraps the text into |
three lines. if you must achieve the previous behavior, adjust the text style |
and, if necessary, the letter spacing. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.