add date locale in list by organizers
This commit is contained in:
parent
909b321158
commit
2e6814c33d
@ -12,10 +12,15 @@ import 'package:intl/date_symbol_data_local.dart';
|
|||||||
import '../variable/globals.dart' as globals;
|
import '../variable/globals.dart' as globals;
|
||||||
import '../classes/MyDrawer.dart';
|
import '../classes/MyDrawer.dart';
|
||||||
import '../classes/auth_service.dart';
|
import '../classes/auth_service.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
// app starting point
|
// app starting point
|
||||||
void main() {
|
void main() async {
|
||||||
initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
await initializeDateFormatting("fr_FR", null);
|
||||||
|
|
||||||
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@ -24,6 +29,14 @@ class MyApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
localizationsDelegates: [
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
],
|
||||||
|
supportedLocales: [
|
||||||
|
const Locale('fr', 'FR'),
|
||||||
|
],
|
||||||
home: const ListItemOrganizers(organizer: "default"),
|
home: const ListItemOrganizers(organizer: "default"),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
);
|
);
|
||||||
@ -81,6 +94,8 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
|||||||
|
|
||||||
// function to fetch data from api and return future list of posts
|
// function to fetch data from api and return future list of posts
|
||||||
static Future<List<Events>> getPosts(organizer, {count = 0}) async {
|
static Future<List<Events>> getPosts(organizer, {count = 0}) async {
|
||||||
|
await initializeDateFormatting("fr_FR", null);
|
||||||
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
final List<Events> body = [];
|
final List<Events> body = [];
|
||||||
@ -160,12 +175,13 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final post = posts[index];
|
final post = posts[index];
|
||||||
final startDate = DateTime.parse(post.startDate!);
|
final startDate = DateTime.parse(post.startDate!);
|
||||||
final date = DateFormat.yMd().format(startDate);
|
|
||||||
final time = DateFormat.Hm().format(startDate);
|
final dateLongue =
|
||||||
|
DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate);
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text('${post.name!}'),
|
title: Text('${post.name!}'),
|
||||||
subtitle: Text('${post.place!}\n${date} ${time}'),
|
subtitle: Text('${post.place!}\n${dateLongue}'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user