text
stringlengths
1
372
),
),
);
}
future<void> _incrementCounter() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
int counter = (prefs.getint('counter') ?? 0) + 1;
await prefs.setInt('counter', counter);
}
<code_end>
<topic_end>
<topic_start>
how do i access SQLite in flutter?
in android, you use SQLite to store structured data
that you can query using SQL.
in flutter, for macOS, android, or iOS,
access this functionality using the
SQFlite plugin.
<topic_end>
<topic_start>
debugging
<topic_end>
<topic_start>
what tools can i use to debug my app in flutter?
use the DevTools suite for debugging flutter or dart apps.
DevTools includes support for profiling, examining the heap,
inspecting the widget tree, logging diagnostics, debugging,
observing executed lines of code, debugging memory leaks and memory
fragmentation. for more information, see the
DevTools documentation.
<topic_end>
<topic_start>
notifications
<topic_end>
<topic_start>
how do i set up push notifications?
in android, you use firebase cloud messaging to set up
push notifications for your app.
in flutter, access this functionality using the
firebase messaging plugin.
for more information on using the firebase cloud messaging API,
see the firebase_messaging plugin documentation.
<topic_end>
<topic_start>
flutter for SwiftUI developers
SwiftUI developers who want to write mobile apps using flutter
should review this guide.
it explains how to apply existing SwiftUI knowledge to flutter.
info note
if you instead have experience building apps for iOS with UIKit,
see flutter for UIKit developers.
flutter is a framework for building cross-platform applications
that uses the dart programming language.
to understand some differences between programming with dart
and programming with swift, see learning dart as a swift developer
and flutter concurrency for swift developers.
your SwiftUI knowledge and experience
are highly valuable when building with flutter.
flutter also makes a number of adaptations
to app behavior when running on iOS and macOS.
to learn how, see platform adaptations.
info
to integrate flutter code into an existing iOS app,
check out add flutter to existing app.
this document can be used as a cookbook by jumping around
and finding questions that are most relevant to your needs.
this guide embeds sample code.
you can test full working examples on DartPad or view them on GitHub.
<topic_end>
<topic_start>
overview
as an introduction, watch the following video.
it outlines how flutter works on iOS and how to use flutter to build iOS apps.
flutter and SwiftUI code describes how the UI looks and works.
developers call this type of code a declarative framework.
<topic_end>
<topic_start>
views vs. widgets
SwiftUI represents UI components as views.
you configure views using modifiers.
flutter represents UI components as widgets.
both views and widgets only exist until they need to be changed.
these languages call this property immutability.
SwiftUI represents a UI component property as a view modifier.
by contrast, flutter uses widgets for both UI components and
their properties.
to compose layouts, both SwiftUI and flutter nest UI components
within one another.
SwiftUI nests views while flutter nests widgets.
<topic_end>
<topic_start>
layout process
SwiftUI lays out views using the following process:
flutter differs somewhat with its process:
flutter differs from SwiftUI because the parent component can override
the child’s desired size. the widget cannot have any size it wants.
it also cannot know or decide its position on screen as its parent
makes that decision.
to force a child widget to render at a specific size,
the parent must set tight constraints.