rfc_3339_date_time_serializer 1.0.1

  • Readme
  • Changelog
  • Installing
  • new62

rfc_3339_date_time_serializer #

An RFC3339DateTimeSerializer serializer class for built_value, created to address the issue about Dart's DateTime.parse not working with RFC 3339.

Why is this package needed? #

ISO 8601 has a character limit for time-secfrac part equal to 6. RFC 3339 does not have that limit. Thanks to this, datetimes introducing more than 6 characters in time-secfrac are invalid for DateTime.parse, because it works only with ISO 8601.

For example, Go's encoding/json serializes dates with 7 time-secfrac characters.

Usage #

In your serializers.dart:

import 'rfc_3339_date_time_serializer/rfc_3339_date_time_serializer.dart';

@SerializersFor(const [/* (...) */])
final Serializers modelsSerializers = (_$modelsSerializers.toBuilder()
      ..addPlugin(StandardJsonPlugin())
      ..add(RFC3339DateTimeSerializer())) // this is the line you need to add
    .build();

[1.0.1]

  • Readme changes and reformatted code.

[1.0.0]

  • Initial commit

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  rfc_3339_date_time_serializer: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:rfc_3339_date_time_serializer/rfc_3339_date_time_serializer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Dec 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:rfc_3339_date_time_serializer/rfc_3339_date_time_serializer.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and rfc_3339_date_time_serializer.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
built_value ^7.0.0 7.0.0
Transitive dependencies
built_collection 4.3.0
collection 1.14.12
fixnum 0.10.11
matcher 0.12.6
meta 1.1.8
path 1.6.4
quiver 2.1.2+1
stack_trace 1.9.3
Dev dependencies
test ^1.0.0