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 '../classes/MyDrawer.dart';
|
||||
import '../classes/auth_service.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
// app starting point
|
||||
void main() {
|
||||
initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await initializeDateFormatting("fr_FR", null);
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@ -24,6 +29,14 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
localizationsDelegates: [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: [
|
||||
const Locale('fr', 'FR'),
|
||||
],
|
||||
home: const ListItemOrganizers(organizer: "default"),
|
||||
debugShowCheckedModeBanner: false,
|
||||
);
|
||||
@ -81,6 +94,8 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
||||
|
||||
// function to fetch data from api and return future list of posts
|
||||
static Future<List<Events>> getPosts(organizer, {count = 0}) async {
|
||||
await initializeDateFormatting("fr_FR", null);
|
||||
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
var accessToken = prefs.getString("access_token") ?? "";
|
||||
final List<Events> body = [];
|
||||
@ -160,12 +175,13 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
||||
itemBuilder: (context, index) {
|
||||
final post = posts[index];
|
||||
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(
|
||||
title: Text('${post.name!}'),
|
||||
subtitle: Text('${post.place!}\n${date} ${time}'),
|
||||
subtitle: Text('${post.place!}\n${dateLongue}'),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
|
Loading…
x
Reference in New Issue
Block a user