Localization in Flutter Date Range Picker (SfDateRangePicker)
27 Jul 20251 minute to read
By default, the SfDateRangePicker 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 your pubspec.yaml file.
dependencies:
flutter_localizations:
sdk: flutterNext, 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),
),
);
}