mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Adding JSON example. (#1)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Copyright 2018 The Chromium Authors. 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:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'serializable_simple_object.g.dart';
|
||||
|
||||
/// An annotation for the code generator to know that this class needs the
|
||||
/// JSON serialization logic to be generated.
|
||||
@JsonSerializable()
|
||||
class SerializableSimpleObject extends Object
|
||||
with _$SerializableSimpleObjectSerializerMixin {
|
||||
SerializableSimpleObject({
|
||||
this.aString,
|
||||
this.anInt,
|
||||
this.aDouble,
|
||||
this.aListOfStrings,
|
||||
this.aListOfInts,
|
||||
this.aListOfDoubles,
|
||||
});
|
||||
|
||||
final String aString;
|
||||
final int anInt;
|
||||
final double aDouble;
|
||||
final List<String> aListOfStrings;
|
||||
final List<int> aListOfInts;
|
||||
final List<double> aListOfDoubles;
|
||||
|
||||
factory SerializableSimpleObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SerializableSimpleObjectFromJson(json);
|
||||
}
|
||||
Reference in New Issue
Block a user