syncfusion_localizations 25.2.3 syncfusion_localizations: ^25.2.3 copied to clipboard
Syncfusion Localizations package contains localized text for 77 cultures for all the applicable Syncfusion Flutter Widgets.
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import 'package:syncfusion_localizations/syncfusion_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
return runApp(CalendarApp());
}
///Renders calendar widget
class CalendarApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Calendar Demo',
//ignore: always_specify_types
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
// ... app-specific localization delegate[s] here
SfGlobalLocalizations.delegate
],
//ignore: always_specify_types
supportedLocales: const [
Locale('en'),
Locale('fr'),
// ... other locales the app supports
],
locale: const Locale('fr'),
home: _MyHomePage(),
);
}
}
class _MyHomePage extends StatefulWidget {
// ignore: prefer_const_constructors_in_immutables
_MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<_MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SfCalendar(
view: CalendarView.month,
dataSource: _MeetingDataSource(_getDataSource()),
monthViewSettings: MonthViewSettings(
appointmentDisplayMode: MonthAppointmentDisplayMode.appointment,
showAgenda: true),
));
}
List<_Meeting> _getDataSource() {
final List<_Meeting> meetings = <_Meeting>[];
final DateTime today = DateTime.now();
final DateTime startTime =
DateTime(today.year, today.month, today.day, 9, 0, 0);
final DateTime endTime = startTime.add(const Duration(hours: 2));
meetings.add(_Meeting(
'Conference', startTime, endTime, const Color(0xFF0F8644), false));
return meetings;
}
}
class _MeetingDataSource extends CalendarDataSource {
_MeetingDataSource(List<_Meeting> source) {
appointments = source;
}
@override
DateTime getStartTime(int index) {
return appointments![index].from;
}
@override
DateTime getEndTime(int index) {
return appointments![index].to;
}
@override
String getSubject(int index) {
return appointments![index].eventName;
}
@override
Color getColor(int index) {
return appointments![index].background;
}
@override
bool isAllDay(int index) {
return appointments![index].isAllDay;
}
}
class _Meeting {
_Meeting(this.eventName, this.from, this.to, this.background, this.isAllDay);
String eventName;
DateTime from;
DateTime to;
Color background;
bool isAllDay;
}