flutter-localization
Installation
SKILL.md
Flutter Localization Setup
Goal
Configures and implements internationalization (i18n) and localization (l10n) in a Flutter application. This skill manages dependency injection (flutter_localizations, intl), code generation configuration (l10n.yaml), root widget setup (MaterialApp, CupertinoApp, or WidgetsApp), .arb translation file management, and platform-specific configurations (iOS Xcode project updates). It ensures proper locale resolution and prevents common assertion errors related to missing localization delegates in specific widgets like TextField and CupertinoTabBar.
Decision Logic
- Determine App Root: Identify if the application uses
MaterialApp,CupertinoApp, orWidgetsAppto inject the correct global delegates. - Identify Target Platforms: If iOS is a target platform, Xcode project files (
Info.plist/project.pbxproj) must be updated to expose supported locales to the App Store. - Analyze Widget Tree: Check for isolated
TextFieldorCupertinoTabBarwidgets that might exist outside the root app's localization scope. If found, wrap them in explicitLocalizationswidgets. - Determine Locale Complexity: If supporting languages with multiple scripts/regions (e.g., Chinese
zh_Hans_CN), useLocale.fromSubtagsinstead of the defaultLocaleconstructor.