// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. import 'package:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart'; enum Category { top, bottom, strange, charmed, up, down, @JsonValue('not_discovered_yet') notDiscoveredYet } enum StatusCode { @JsonValue(200) success, @JsonValue(404) notFound } Duration durationFromInt(int ms) => Duration(milliseconds: ms); int durationToInt(Duration duration) => duration.inMilliseconds; DateTime dateTimeFromEpochUs(int us) => DateTime.fromMicrosecondsSinceEpoch(us); int dateTimeToEpochUs(DateTime dateTime) => dateTime.microsecondsSinceEpoch; bool deepEquals(a, b) => const DeepCollectionEquality().equals(a, b); class Platform { final String description; static const Platform foo = Platform._('foo'); static const Platform undefined = Platform._('undefined'); const Platform._(this.description); factory Platform.fromJson(String value) { switch (value) { case 'foo': return foo; case 'undefined': return undefined; default: throw ArgumentError.value(value, 'value', 'Not a supported value.'); } } String toJson() => description; } abstract class ItemCore { final int price; ItemCore(this.price); }