text
stringlengths 1
474
|
---|
<topic_end>
|
<topic_start>
|
Navigating to another app
|
In UIKit, to send the user to another application,
|
you use a specific URL scheme.
|
For the system level apps, the scheme depends on the app.
|
To implement this functionality in Flutter,
|
create a native platform integration, or use an
|
existing plugin, such as url_launcher.<topic_end>
|
<topic_start>
|
Manually pop back
|
Calling SystemNavigator.pop() from your Dart code
|
invokes the following iOS code:If that doesn’t do what you want, you can create your own
|
platform channel to invoke arbitrary iOS code.<topic_end>
|
<topic_start>
|
Handling localization
|
Unlike iOS, which has the Localizable.strings file,
|
Flutter doesn’t currently have a dedicated system for handling strings.
|
At the moment, the best practice is to declare your copy text
|
in a class as static fields and access them from there. For example:
|
<code_start>class Strings {
|
static const String welcomeMessage = 'Welcome To Flutter';
|
}<code_end>
|
You can access your strings as such:
|
<code_start>Text(Strings.welcomeMessage);<code_end>
|
By default, Flutter only supports US English for its strings.
|
If you need to add support for other languages,
|
include the flutter_localizations package.
|
You might also need to add Dart’s intl
|
package to use i10n machinery, such as date/time formatting.To use the flutter_localizations package,
|
specify the localizationsDelegates and
|
supportedLocales on the app widget:
|
<code_start>import 'package:flutter/material.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
class MyWidget extends StatelessWidget {
|
const MyWidget({super.key});
|
@override
|
Widget build(BuildContext context) {
|
return const MaterialApp(
|
localizationsDelegates: <LocalizationsDelegate<dynamic>>[
|
// Add app-specific localization delegate[s] here
|
GlobalMaterialLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
],
|
supportedLocales: <Locale>[
|
Locale('en', 'US'), // English
|
Locale('he', 'IL'), // Hebrew
|
// ... other locales the app supports
|
],
|
);
|
}
|
}<code_end>
|
The delegates contain the actual localized values,
|
while the supportedLocales defines which locales the app supports.
|
The above example uses a MaterialApp,
|
so it has both a GlobalWidgetsLocalizations
|
for the base widgets localized values,
|
and a MaterialWidgetsLocalizations for the Material widgets localizations.
|
If you use WidgetsApp for your app, you don’t need the latter.
|
Note that these two delegates contain “default” values,
|
but you’ll need to provide one or more delegates
|
for your own app’s localizable copy,
|
if you want those to be localized too.When initialized, the WidgetsApp (or MaterialApp)
|
creates a Localizations widget for you,
|
with the delegates you specify.
|
The current locale for the device is always accessible
|
from the Localizations widget from the current context
|
(in the form of a Locale object), or using the Window.locale.To access localized resources, use the Localizations.of() method
|
to access a specific localizations class that is provided by a given delegate.
|
Use the intl_translation package to extract translatable copy
|
to arb files for translating, and importing them back into the app
|
for using them with intl.For further details on internationalization and localization in Flutter,
|
see the internationalization guide, which has sample code
|
with and without the intl package.<topic_end>
|
<topic_start>
|
Managing dependencies
|
In iOS, you add dependencies with CocoaPods by adding to your Podfile.
|
Flutter uses Dart’s build system and the Pub package manager
|
to handle dependencies. The tools delegate the building of the
|
native Android and iOS wrapper apps to the
|
respective build systems.While there is a Podfile in the iOS folder in your
|
Flutter project, only use this if you are adding native
|
dependencies needed for per-platform integration.
|
In general, use pubspec.yaml to declare external dependencies in Flutter.
|
A good place to find great packages for Flutter is on pub.dev.<topic_end>
|
<topic_start>
|
ViewControllers
|
This section of the document discusses the equivalent
|
of ViewController in Flutter and how to listen to
|
lifecycle events.<topic_end>
|
<topic_start>
|
Equivalent of ViewController in Flutter
|
In UIKit, a ViewController represents a portion of user interface,
|
most commonly used for a screen or section.
|
These are composed together to build complex user interfaces,
|
and help scale your application’s UI.
|
In Flutter, this job falls to Widgets.
|
As mentioned in the Navigation section,
|
screens in Flutter are represented by Widgets since
|
“everything is a widget!”
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.