FadyFayezYounan / easy_date_timeline

The "easy_date_timeline" package is a customizable Flutter widget that displays a timeline of dates in a horizontal timeline.
MIT License
96 stars 46 forks source link

Locale data has not been initialized, call initializeDateFormatting(<locale>) #22

Closed yagizdo closed 8 months ago

yagizdo commented 9 months ago

I am encountering a sporadic issue with locale settings in my Flutter application. Specifically, the application throws an error related to locale settings whenever I try to set the locale to anything other than the default.

This error occurs with various locales (tr, ar, etc.), including attempts to set the locale explicitly to English (en or en_US). Interestingly, the issue temporarily resolves itself without any changes on my part, only to reappear later under the same conditions.

Package version : easy_date_timeline: ^1.0.4 Flutter Version: Flutter 3.16.5 Dart Version: Dart 3.2.3 Test Simulator: iPhone 13 - iOS 15.0

Error :

======== Exception caught by widgets library =======================================================
The following LocaleDataException was thrown building:
Locale data has not been initialized, call initializeDateFormatting(<locale>).

When the exception was thrown, this was the stack: 
#0      UninitializedLocaleData._throwException (package:intl/src/intl_helpers.dart:80:5)
#1      UninitializedLocaleData.containsKey (package:intl/src/intl_helpers.dart:74:7)
#2      DateFormat.localeExists (package:intl/src/intl/date_format.dart:902:28)
#3      verifiedLocale (package:intl/src/intl_helpers.dart:185:19)
#4      new DateFormat (package:intl/src/intl/date_format.dart:267:27)
#5      EasyDateFormatter.shortDayName (package:easy_date_timeline/src/utils/easy_date_formatter.dart:7:12)
#6      _InfiniteTimeLineWidgetState._dayItemBuilder (package:easy_date_timeline/src/easy_infinite_date_time/widgets/infinite_time_line_widget.dart:269:27)
#7      _InfiniteTimeLineWidgetState.build.<anonymous closure> (package:easy_date_timeline/src/easy_infinite_date_time/widgets/infinite_time_line_widget.dart:224:27)
#8      SliverChildBuilderDelegate.build (package:flutter/src/widgets/scroll_delegate.dart:490:22)
#9      SliverMultiBoxAdaptorElement._build (package:flutter/src/widgets/sliver.dart:829:28)
#10     SliverMultiBoxAdaptorElement.performRebuild.processElement (package:flutter/src/widgets/sliver.dart:759:67)
#11     Iterable.forEach (dart:core/iterable.dart:347:35)
#12     SliverMultiBoxAdaptorElement.performRebuild (package:flutter/src/widgets/sliver.dart:806:24)
#13     SliverMultiBoxAdaptorElement.update (package:flutter/src/widgets/sliver.dart:735:7)
#14     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#15     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#16     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#17     Element.updateChildren (package:flutter/src/widgets/framework.dart:3964:32)
#18     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896:17)
#19     _ViewportElement.update (package:flutter/src/widgets/viewport.dart:235:11)
#20     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#21     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#22     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#23     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#24     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#25     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#26     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#27     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#28     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#29     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#30     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#31     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#32     StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#33     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#34     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#35     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#36     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#37     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#38     ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#39     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#40     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#41     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#42     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#43     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#44     ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#45     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#46     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#47     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#48     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#49     StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#50     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#51     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#52     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#53     StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
#54     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#55     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#56     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#57     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#58     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#59     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#60     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#61     StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
#62     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#63     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#64     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#65     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#66     StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#67     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#68     Element.updateChildren (package:flutter/src/widgets/framework.dart:3964:32)
#69     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896:17)
#70     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#71     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#72     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#73     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#74     StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#75     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#76     Element.updateChildren (package:flutter/src/widgets/framework.dart:3964:32)
#77     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896:17)
#78     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#79     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#80     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#81     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#82     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#83     ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#84     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#85     Element.updateChildren (package:flutter/src/widgets/framework.dart:3964:32)
#86     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896:17)
#87     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#88     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#89     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#90     StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
#91     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#92     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#93     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#94     ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#95     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#96     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#97     Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#98     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#99     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#100    StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
#101    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#102    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#103    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#104    StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
#105    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#106    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#107    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#108    StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
#109    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#110    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#111    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#112    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#113    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#114    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#115    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#116    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#117    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#118    Element.updateChildren (package:flutter/src/widgets/framework.dart:3964:32)
#119    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896:17)
#120    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#121    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#122    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#123    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#124    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#125    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#126    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#127    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#128    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#129    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#130    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#131    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#132    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#133    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#134    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#135    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#136    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#137    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#138    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#139    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#140    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#141    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#142    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#143    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#144    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#145    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#146    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#147    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#148    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#149    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#150    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14)
#151    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#152    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#153    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#154    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#155    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#156    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#157    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#158    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#159    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#160    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#161    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#162    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#163    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#164    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#165    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#166    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#167    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#168    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#169    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#170    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#171    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#172    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#173    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#174    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#175    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#176    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#177    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#178    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#179    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#180    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#181    ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
#182    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#183    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#184    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#185    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#186    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#187    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#188    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#189    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#190    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#191    StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
#192    Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
#193    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#194    Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#195    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2895:19)
#196    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:984:21)
#197    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5)
#198    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
#199    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9)
#200    SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:978:7)
#204    _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
(elided 3 frames from class _Timer and dart:async-patch)
====================================================================================================

Calendar View :

import 'package:easy_date_timeline/easy_date_timeline.dart';
import 'package:egzersiz_saati/utils/extensions/context_extension.dart';
import 'package:flutter/material.dart';

import '../../../../../widgets/main_widgets/main_appbar.dart';
import '../../../../../widgets/main_widgets/main_layout.dart';
import '../widget/date_card.dart';

class CalendarView extends StatelessWidget {
  const CalendarView({super.key});

  @override
  Widget build(BuildContext context) {
    return MainLayout(
      content: context.isLittlePhone
          ? smallPhoneLayout(context)
          : context.isMiddlePhone
              ? middlePhoneLayout(context)
              : bigPhoneLayout(context),
    );
  }

  Widget bigPhoneLayout(BuildContext context) {
    return _buildBody(context);
  }

  Widget middlePhoneLayout(BuildContext context) {
    return _buildBody(context);
  }

  Widget smallPhoneLayout(BuildContext context) {
    return _buildBody(context);
  }

  Widget _buildBody(BuildContext context) {
    return Column(children: [
      const MainAppBar(
        title: "Takvim",
        isDetail: true,
      ),
      Expanded(child: _buildContent(context)),
    ]);
  }

  Widget _buildContent(BuildContext context) {
    final EasyInfiniteDateTimelineController _controller =
        EasyInfiniteDateTimelineController();
    return Padding(
      padding: EdgeInsets.only(
        top: context.screenWidth * 0.04,
        left: context.screenWidth * 0.04,
        right: context.screenWidth * 0.04,
      ),
      child: Column(
        children: [
          EasyInfiniteDateTimeLine(
            controller: _controller,
            firstDate: DateTime(2024),
            focusDate: DateTime.now(),
            lastDate: DateTime(2099, 12, 31),
            locale: 'tr',
            showTimelineHeader: false,
            itemBuilder: (
              context,
              String dayNumber,
              String dayName,
              String monthName,
              DateTime fullDate,
              bool isSelected,
            ) {
              return DateCard(
                dayNumber: dayNumber,
                dayName: dayName,
                monthName: monthName,
                fullDate: fullDate,
                isSelected: isSelected,
              );
            },
            onDateChange: (selectedDate) {
              print(selectedDate.toIso8601String());
            },
          ),
        ],
      ),
    );
  }
}
FadyFayezYounan commented 9 months ago

I'm sorry for the late reply. check it now. WhatsApp Image 2024-02-17 at 14 05 43_27fe3270

yagizdo commented 8 months ago

Thanks for the quick fix. Can you take a look at pull request #23 when you get a chance?

FadyFayezYounan commented 8 months ago

I have accepted the pull request. Thank you for your excellent effort

yagizdo commented 8 months ago

Thank you very much! I'm grateful for accepting my pull request. I'm happy to have contributed to your package. Keep up the great work!