text stringlengths 1 474 |
|---|
<topic_start>Flutter fix |
As Flutter continues to evolve, we provide a tool to help you clean up |
deprecated APIs from your codebase. The tool ships as part of Flutter, and |
suggests changes that you might want to make to your code. The tool is available |
from the command line, and is also integrated into the IDE plugins for Android |
Studio and Visual Studio Code.lightbulb Tip |
These automated updates are called quick-fixes in IntelliJ and Android |
Studio, and code actions in VS Code.<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 FlutterTo 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 |
Flutter, including the core principles and concepts that form its design.Flutter is a cross-platform UI toolkit that is designed to allow code reuse |
across operating systems such as iOS and Android, while also allowing |
applications to interface directly with underlying platform services. The goal |
is to enable developers to deliver high-performance apps that feel natural on |
different platforms, embracing differences where they exist while sharing as |
much code as possible.During development, Flutter apps run in a VM that offers stateful hot reload of |
changes without needing a full recompile. For release, Flutter apps are compiled |
directly to machine code, whether Intel x64 or ARM instructions, or to |
JavaScript if targeting the web. The framework is open source, with a permissive |
BSD license, and has a thriving ecosystem of third-party packages that |
supplement the core library functionality.This overview is divided into a number of sections:<topic_end> |
<topic_start> |
Architectural layers |
Flutter is designed as an extensible, layered system. It exists as a series of |
independent libraries that each depend on the underlying layer. No layer has |
privileged access to the layer below, and every part of the framework level is |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.