srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
102 stars 53 forks source link

Timezone assets not loaded on aws ec2 server #133

Closed Sasikumar3595 closed 1 year ago

Sasikumar3595 commented 2 years ago

We are creating a new widget with timezone package, and the package makes an error while loading the widget on aws ec2 server.

It shows the error below:

Uncaught Unable to load asset: packages/timezone/data/2020a.tzf

Error screenshots:

Screen Shot 2022-04-22 at 4 47 38 PM

Sasikumar3595 commented 2 years ago

@srawlins

Any update/suggestion on this?

Nijamudeen-Mohamed commented 2 years ago

Hi Team, Expecting a rapid solution to this. do the needful.

srawlins commented 2 years ago

Thanks for your question. Questions like this are better asked on a large programming forum like StackOverflow, with more eyes to look at a question. I cannot answer your question here without you are initializing from the dart library, without seeing the initialization code, without knowing the version of the timezone package used. This would be good information to include in a post to StackOverflow. Also it would be good to indicate why you are requesting the 2020a database, and not the latest.

Sasikumar3595 commented 2 years ago

@srawlins ,

Code sample:


@override
  void initState() {
    _loadDataBase();
    super.initState();
  }

  Future<bool> _loadDataBase() async {
    final ByteData byteData =
    await rootBundle.load('packages/timezone/data/2020a.tzf');
    initializeDatabase(byteData.buffer.asUint8List());
    return true;
  }

  void _refresh() {
    DateTime date = DateTime.now();
    Location location = getLocation('Australia/Darwin');
    DateTime convertedDate = TZDateTime.from(date, location);
    print(convertedDate);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(

        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _refresh,
        tooltip: 'Convert Date',
        child: const Icon(Icons.refresh),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

TimeZone package: timezone 0.8.0

Note: It was working fine on other than aws ec2 servers.

ranjithsan commented 2 years ago

@srawlins please update on how this can be fixed...We are working on a crucial project and all was working fine during dev and when we moved the code to aws..it stopped working.... your help is greatly appreciated...

srawlins commented 1 year ago

Sorry about the crucial project. Please try a user forum.

Sasikumar3595 commented 1 year ago

@srawlins ,

We asked the same on StackOverFlow forum also StackOverFlow link: https://stackoverflow.com/questions/72008671/widget-assets-are-not-loaded-on-aws-ec2-server

hs-dev1 commented 7 months ago

for this issue you need to add MIME TYPE into your server, so it can accept the file type of .tzf and it will work fine.

Here is the solution.

https://github.com/syncfusion/flutter-examples/issues/450