---
title: "How to programmatically change the locale in Flutter?"
description: "There are several ways this can be done. The main thing is to explicitly set the `locale` prop of the `MaterialApp` widget on language change."
category: flutter
date: 2023-02-01
updated: 2026-10-09
canonical: https://localizely.com/i18n-questions/flutter/how-to-programmatically-change-the-locale-in-flutter/
---

# How to programmatically change the locale in Flutter?


There are several ways this can be done.  
The main thing is to explicitly set the `locale` prop of the `MaterialApp` widget on language change.  
Below, you can find an example of how to do that using the [**provider**](https://pub.dev/packages/provider) package.

```dart highlight="21"
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'l10n/app_localizations.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => LocaleModel(),
      child: Consumer<LocaleModel>(
        builder: (context, localeModel, child) => MaterialApp(
          title: 'Your app title',
          localizationsDelegates: AppLocalizations.localizationsDelegates,
          supportedLocales: AppLocalizations.supportedLocales,
          locale: localeModel.locale,
          /* ... */
        ),
      ),
    );
  }
}

class LocaleModel extends ChangeNotifier {
  Locale? _locale;

  Locale? get locale => _locale;

  void set(Locale locale) {
    _locale = locale;
    notifyListeners();
  }
}
```

> For more details, please check out an example on [GitHub](https://github.com/localizely/flutter-gen-l10n-example).

Source: https://localizely.com/i18n-questions/flutter/how-to-programmatically-change-the-locale-in-flutter/
