We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to override the Material app locale and set English language for Flutter Calendar


In Flutter, override the Material app locale with different locale by using the Localization.override constructor.

The SfCalendar and SfDateRangePicker control is present in the Column widget. Place the SfCalendar in the Localization.override constructor in which the inherited locale (defined in Material app locale) or LocalizationsDelegate for child has been overridden with English language for SfCalendar and SfDateRangePicker has Material app locale.

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
 
void main() => runApp(LocalizationSupport());
 
class LocalizationSupport extends StatelessWidget {
 
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('en'),
        const Locale('zh'),
        const Locale('he'),
        const Locale('ru'),
        const Locale('fr', 'BE'),
        const Locale('fr', 'CA'),
        const Locale('ja'),
        const Locale('de'),
        const Locale('hi'),
        const Locale('ar'),
      ],
      locale: const Locale('zh'),
      debugShowCheckedModeBanner: false,
      home: CustomStringLocale(),
    );
  }
}
 
class CustomStringLocale extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => ScheduleExample();
}
 
class ScheduleExample extends State<CustomStringLocale> {
  @override
  Widget build(BuildContext context) {
    return (Scaffold(
      body: Column(
        children: [
          Localizations.override(
            context: context,
            locale: Locale('en'),
            child: Expanded(child: SfCalendar()),
          ),
          SfDateRangePicker()
        ],
      ),
    ));
  }
}

View sample in GitHub

Widgets with locale

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile