text stringlengths 1 474 |
|---|
// Checks that tappable nodes have a minimum size of 44 by 44 pixels |
// for iOS. |
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline)); |
// Checks that touch targets with a tap or long press action are labeled. |
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); |
// Checks whether semantic nodes meet the minimum text contrast levels. |
// The recommended text contrast is 3:1 for larger text |
// (18 point and above regular). |
await expectLater(tester, meetsGuideline(textContrastGuideline)); |
handle.dispose();<code_end> |
You can add Guideline API tests |
in test/widget_test.dart of your app directory, or as a separate test |
file (such as test/a11y_test.dart in the case of the Name Generator).<topic_end> |
<topic_start> |
Testing accessibility on web |
You can debug accessibility by visualizing the semantic nodes created for your web app |
using the following command line flag in profile and release modes:With the flag activated, the semantic nodes appear on top of the widgets; |
you can verify that the semantic elements are placed where they should be. |
If the semantic nodes are incorrectly placed, please file a bug report.<topic_end> |
<topic_start> |
Accessibility release checklist |
Here is a non-exhaustive list of things to consider as you prepare your |
app for release.<topic_end> |
<topic_start> |
Learn more |
To learn more about Flutter and accessibility, check out |
the following articles written by community members: |
<topic_end> |
<topic_start>Internationalizing Flutter apps |
<topic_end> |
<topic_start>What you'll learn |
If your app might be deployed to users who speak another |
language then you’ll need to internationalize it. |
That means you need to write the app in a way that makes |
it possible to localize values like text and layouts |
for each language or locale that the app supports. |
Flutter provides widgets and classes that help with |
internationalization and the Flutter libraries |
themselves are internationalized.This page covers concepts and workflows necessary to |
localize a Flutter application using the |
MaterialApp and CupertinoApp classes, |
as most apps are written that way. |
However, applications written using the lower level |
WidgetsApp class can also be internationalized |
using the same classes and logic.<topic_end> |
<topic_start> |
Introduction to localizations in Flutter |
This section provides a tutorial on how to create and |
internationalize a new Flutter application, |
along with any additional setup |
that a target platform might require.You can find the source code for this example in |
gen_l10n_example.<topic_end> |
<topic_start> |
Setting up an internationalized app: the Flutter_localizations package |
By default, Flutter only provides US English localizations. |
To add support for other languages, |
an application must specify additional |
MaterialApp (or CupertinoApp) properties, |
and include a package called flutter_localizations. |
As of December 2023, this package supports 115 languages |
and language variants.To begin, start by creating a new Flutter application |
in a directory of your choice with the flutter create command.To use flutter_localizations, |
add the package as a dependency to your pubspec.yaml file, |
as well as the intl package:This creates a pubspec.yml file with the following entries: |
<code_start>dependencies: |
flutter: |
sdk: flutter |
flutter_localizations: |
sdk: flutter |
intl: any<code_end> |
Then import the flutter_localizations library and specify |
localizationsDelegates and supportedLocales for |
your MaterialApp or CupertinoApp: |
<code_start>import 'package:flutter_localizations/flutter_localizations.dart';<code_end> |
<code_start>return const MaterialApp( |
title: 'Localizations Sample App', |
localizationsDelegates: [ |
GlobalMaterialLocalizations.delegate, |
GlobalWidgetsLocalizations.delegate, |
GlobalCupertinoLocalizations.delegate, |
], |
supportedLocales: [ |
Locale('en'), // English |
Locale('es'), // Spanish |
], |
home: MyHomePage(), |
);<code_end> |
After introducing the flutter_localizations package |
and adding the previous code, |
the Material and Cupertino |
packages should now be correctly localized in |
one of the 115 supported locales. |
Widgets should be adapted to the localized messages, |
along with correct left-to-right or right-to-left layout.Try switching the target platform’s locale to |
Spanish (es) and the messages should be localized.Apps based on WidgetsApp are similar except that the |
GlobalMaterialLocalizations.delegate isn’t needed.The full Locale.fromSubtags constructor is preferred |
as it supports scriptCode, though the Locale default |
constructor is still fully valid.The elements of the localizationsDelegates list are |
factories that produce collections of localized values. |
GlobalMaterialLocalizations.delegate provides localized |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.