Localization in Flutter Date Range Picker (SfDateRangePicker)

30 May 20221 minute to read

By default, the calendar widget supports US English localizations. You can change other languages by specifying the MaterialApp properties and adding the flutter_localizations package to your application.

To use flutter_localizations, add the package as a dependency to pubspec.yaml file.

  • DART
  • dependencies:
    flutter_localizations:
      sdk: flutter

    Next, import the flutter_localizations library and specify localizationsDelegates and supportedLocale for MaterialApp.

    import 'package:flutter_localizations/flutter_localizations.dart';
    
    @override
    Widget build(BuildContext context) {
    return MaterialApp(
            localizationsDelegates: [
                GlobalMaterialLocalizations.delegate,
                GlobalWidgetsLocalizations.delegate,
          ],
         supportedLocales: [
              const Locale('zh'),
              const Locale('ar'),
              const Locale('ja'),
          ],
          locale: const Locale('zh'),
          title: 'DateRangePicker Localization',
          home: Scaffold(
              appBar: AppBar(
              title: Text('Calendar'),
              ),
              body: SfDateRangePicker(
              view: DateRangePickerView.month,
               ),
           ),
       );
    }

    Localization Date Range Picker