text
stringlengths
1
372
<topic_end>
<topic_start>
applying individual fixes
you can use any supported IDE
to apply a single fix at a time.
<topic_end>
<topic_start>
IntelliJ and android studio
when the analyzer detects a deprecated API,
a light bulb appears on that line of code.
clicking the light bulb displays the suggested fix
that updates that code to the new API.
clicking the suggested fix performs the update.
a sample quick-fix in IntelliJ
<topic_end>
<topic_start>
VS code
when the analyzer detects a deprecated API,
it presents an error.
you can do any of the following:
hover over the error and then click the
quick fix link.
this presents a filtered list showing
only fixes.
put the caret in the code with the error and click
the light bulb icon that appears.
this shows a list of all actions, including
refactors.
put the caret in the code with the error and
press the shortcut
(command+. on macOS, control+. elsewhere)
this shows a list of all actions, including
refactors.
a sample code action in VS code
<topic_end>
<topic_start>
applying project-wide fixes
dart fix decoding flutter
to see or apply changes to an entire project,
you can use the command-line tool, dart fix.
this tool has two options:
to see a full list of available changes, run
the following command:
to apply all changes in bulk, run the
following command:
for more information on flutter deprecations, see
deprecation lifetime in flutter, a free article
on flutter’s medium publication.
<topic_end>
<topic_start>
code formatting
while your code might follow any preferred style—in our
experience—teams of developers might find it more productive to:
the alternative is often tiring formatting debates during code reviews,
where time might be better spent on code behavior rather than code style.
<topic_end>
<topic_start>
automatically formatting code in VS code
install the flutter extension (see
editor setup)
to get automatic formatting of code in VS code.
to automatically format the code in the current source code window,
right-click in the code window and select format document.
you can add a keyboard shortcut to this VS code preferences.
to automatically format code whenever you save a file, set the
editor.formatOnSave setting to true.
<topic_end>
<topic_start>
automatically formatting code in android studio and IntelliJ
install the dart plugin (see
editor setup)
to get automatic formatting of code in android studio and IntelliJ.
to format your code in the current source code window:
android studio and IntelliJ also provide a checkbox named
format code on save on the flutter page in preferences
on macOS or settings on windows and linux.
this option corrects formatting in the current file when you save it.
<topic_end>
<topic_start>
automatically formatting code with the dart command
to correct code formatting in the command line interface (cli),
run the dart format command:
<topic_end>
<topic_start>
using trailing commas
flutter code often involves building fairly deep tree-shaped data structures,
for example in a build method. to get good automatic formatting,
we recommend you adopt the optional trailing commas.
the guideline for adding a trailing comma is simple: always
add a trailing comma at the end of a parameter list in
functions, methods, and constructors where you care about
keeping the formatting you crafted.
this helps the automatic formatter to insert an appropriate
amount of line breaks for flutter-style code.
here is an example of automatically formatted code with trailing commas:
and the same code automatically formatted code without trailing commas:
<topic_end>
<topic_start>
flutter architectural overview
this article is intended to provide a high-level overview of the architecture of