Flutter Android
Flutter Android
Set up an editor
Get started
Set up an editor
You can build apps with Flutter using any text editor or
integrated development environment (IDE) combined with
Flutter’s command-line tools. The Flutter team recommends
using an editor that supports a Flutter extension or plugin, like
VS Code and Android Studio. These plugins provide code
completion, syntax highlighting, widget editing assists, run &
debug support, and more.
If you choose another IDE, skip ahead to the next step: Test
drive.
Install VS Code
VS Code is a code editor to build and debug apps. With the
Flutter extension installed, you can compile, deploy, and debug
Flutter apps.
To install the latest version of VS Code, follow Microsoft’s
instructions for the relevant platform:
• Install on macOS
• Install on Windows
• Install on Linux
4 Type doctor.
5 Select the Flutter: Run Flutter Doctor. Flutter Doctor
runs and its response displays in the Output panel.
6 Automated
Flutter builds
with Bitrise
Out-of-the-box support for your Flutter apps. Build
Flutter apps for both iOS and Android and use our
Flutter Steps to build, test, and deploy them.
Hot reload
Tools
Hot reload
Flutter’s hot reload feature helps you quickly and easily
experiment, build UIs, add features, and fix bugs. Hot reload
works by injecting updated source code files into the running
Dart Virtual Machine (VM). After the VM updates classes with
the new versions of fields and functions, the Flutter framework
automatically rebuilds the widget tree, allowing you to quickly
view the effects of your changes.
How to perform a hot
reload
To hot reload a Flutter app:
content_copy
Performing hot reload...
Reloaded 1 of 448 libraries in 978ms.
The app updates to reflect your change, and the current state
of the app is preserved. Your app continues to execute from
where it was prior to run the hot reload command. The code
updates and execution continues.
Controls for run, run debug, hot reload, and hot restart in
Android Studio
Special cases
The next sections describe specific scenarios that involve hot
reload. In some cases, small changes to the Dart code enable
you to continue using hot reload for your app. In other cases, a
hot restart, or a full restart is needed.
An app is killed
Hot reload can break when the app is killed. For example, if the
app was in the background for too long.
Compilation errors
When a code change introduces a compilation error, hot reload
generates an error message similar to:
content_copy
Hot reload was rejected:
'/path/to/project/lib/main.dart': warning: line 16 pos 38: unbalanced '{'
opens here
Widget build(BuildContext context) {
^
'/path/to/project/lib/main.dart': error: line 33 pos 5: unbalanced ')'
);
^
In this situation, simply correct the errors on the specified lines
of Dart code to keep using hot reload.
CupertinoTabView’s builder
Hot reload won’t apply changes made to a builder of a
CupertinoTabView. For more information, see Issue 43574.
Enumerated types
Hot reload doesn’t work when enumerated types are changed
to regular classes or regular classes are changed to
enumerated types.
For example:
content_copy
enum Color {
red,
green,
blue,
}
After the change:
content_copy
class Color {
Color(this.i, this.j);
final int i;
final int j;
}
Generic types
Hot reload won’t work when generic type declarations are
modified. For example, the following won’t work:
content_copy
class A<T> {
T? i;
}
After the change:
content_copy
class A<T, V> {
T? i;
V? v;
}
Native code
If you’ve changed native code (such as Kotlin, Java, Swift, or
Objective-C), you must perform a full restart (stop and restart
the app) to see the changes take effect.
content_copy
final sampleTable = [
Table(
children: const [
TableRow(
children: [Text('T1')],
)
],
),
Table(
children: const [
TableRow(
children: [Text('T2')],
)
],
),
Table(
children: const [
TableRow(
children: [Text('T3')],
)
],
),
Table(
children: const [
TableRow(
children: [Text('T4')],
)
],
),
];
After running the app, you make the following change:
content_copy
final sampleTable = [
Table(
children: const [
TableRow(
children: [Text('T1')],
)
],
),
Table(
children: const [
TableRow(
children: [Text('T2')],
)
],
),
Table(
children: const [
TableRow(
children: [Text('T3')],
)
],
),
Table(
children: const [
TableRow(
children: [Text('T10')], // modified
)
],
),
];
You hot reload, but the change is not reflected.
content_copy
const foo = 1;
final bar = foo;
void onClick() {
print(foo);
print(bar);
}
Running the app for the first time prints 1 and 1. Then, you
make the following change:
content_copy
const foo = 2; // modified
final bar = foo;
void onClick() {
print(foo);
print(bar);
}
While changes to const field values are always hot reloaded, the
static field initializer is not rerun. Conceptually, const fields are
treated like aliases instead of state.
content_copy
final bar = foo;
To update foo and view the change after hot reload, consider
redefining the field as const or using a getter to return the value,
rather than using final. For example, either of the following
solutions work:
content_copy
const foo = 1;
const bar = foo; // Convert foo to a const...
void onClick() {
print(foo);
print(bar);
}
content_copy
const foo = 1;
int get bar => foo; // ...or provide a getter.
void onClick() {
print(foo);
print(bar);
}
For more information, read about the differences between the
const and final keywords in Dart.
content_copy
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
@override
Widget build(BuildContext context) {
return GestureDetector(onTap: () => print('tapped'));
}
}
After running this app, change the code as follows:
content_copy
import 'package:flutter/widgets.dart';
void main() {
runApp(const Center(child: Text('Hello', textDirection:
TextDirection.ltr)));
}
With a hot restart, the program starts from the beginning,
executes the new version of main(), and builds a widget tree
that displays the text Hello.
However, if you hot reload the app after this change, main() and
initState() are not re-executed, and the widget tree is rebuilt with
the unchanged instance of MyApp as the root widget. This
results in no visible change after hot reload.
How it works
When hot reload is invoked, the host machine looks at the
edited code since the last compilation. The following libraries
are recompiled:
The Dart VM re-loads all libraries from the new kernel file. So
far no code is re-executed.
bug_report
Set up an editor
Get started
Set up an editor
You can build apps with Flutter using any text editor or
integrated development environment (IDE) combined with
Flutter’s command-line tools. The Flutter team recommends
using an editor that supports a Flutter extension or plugin, like
VS Code and Android Studio. These plugins provide code
completion, syntax highlighting, widget editing assists, run &
debug support, and more.
If you choose another IDE, skip ahead to the next step: Test
drive.
Install VS Code
VS Code is a code editor to build and debug apps. With the
Flutter extension installed, you can compile, deploy, and debug
Flutter apps.
• Install on macOS
• Install on Windows
• Install on Linux
Install the VS Code
Flutter extension
1 Start VS Code.
4 Type doctor.
350+ integrations
The Bitrise Step library has over 350 integrations with mobile
tooling and is ever-expanding. Integrate with most third-party
mobile tools to manage your dependencies, run your tests, or
deploy your app. Missing anything? Request or build it yourself!
The best
integrations for
Flutter builds
Integrating with all the tools you love and use for testing,
distribution, and notification.
Flutter Install
Install the Flutter SDK on your build machine: Choose the
version you want to use or stick to the latest stable one.
Flutter Analyze
Run the `flutter analyze` command in any Flutter build to check
your code with the Dart analyzer.
Flutter Build
Build and deploy your Flutter apps for both Android and iOS
with their own customized configurations.
Flutter Test
Run integration tests, unit tests, and widget tests that are
written for Flutter builds. Use any of the available flags for the
`flutter test` command.
Continuous
Integration for
Flutter builds
Get cross-platform and third-party support, automated
workflow configuration, custom plans, and more
continuous integration for your Flutter build — you name
it, we have it.
350+ integrations
The Bitrise Step library has over 350 integrations with mobile
tooling and is ever-expanding. Integrate with most third-party
mobile tools to manage your dependencies, run your tests, or
deploy your app. Missing anything? Request or build it yourself!
The best
integrations for
Flutter builds
Integrating with all the tools you love and use for testing,
distribution, and notification.
Flutter Install
Install the Flutter SDK on your build machine: Choose the
version you want to use or stick to the latest stable one.
Flutter Analyze
Run the `flutter analyze` command in any Flutter build to check
your code with the Dart analyzer.
Flutter Build
Build and deploy your Flutter apps for both Android and iOS
with their own customized configurations.
Flutter Test
Run integration tests, unit tests, and widget tests that are
written for Flutter builds. Use any of the available flags for the
`flutter test` command.