Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Riverpod Localization

A demonstration of using Riverpod for dynamic locale switching in-app, with persistence.

How It Works

Locale Changes

Platform Locale

The Platform.locale property of dart:io library only works on mobile. For web, we need to use dart:html‘s window.navigator.language. This is implemented with the PlatformLocale() interface and conditional imports.

Dependencies

Getting Started

Code Generator: This app uses build_runner to generate code for freezed.

# flutter pub run build_runner build --delete-conflicting-outputs

Download source code on GitHub

Exit mobile version