Skip to content

Adding shrine. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
os:
- linux
sudo: false
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++6
- fonts-droid
git:
depth: 3
env:
- FLUTTER_VERSION=beta
- FLUTTER_VERSION=dev
matrix:
allow_failures:
- env: FLUTTER_VERSION=dev
before_script:
- git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION
- ./flutter/bin/flutter doctor
- chmod +x travis_script.sh
script:
- ./travis_script.sh
cache:
directories:
- $HOME/shared/.pub-cache
37 changes: 30 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
Want to contribute? Great! First, read this page (including the small print at
the end).
# Contributing

### Before you contribute
Want to contribute to the Flutter sample ecosystem? Great! First, read this
page (including the small print at the end).

## Is this the right place for your contribution?

This repo is used by members of the Flutter team and a few partners as a place
to store example apps and demos. It's not meant to be the one and only source of
truth for Flutter samples or the only place people go to learn about the best
ways to build with Flutter. What that means in practice is that if you've
written a great example app, it doesn't need to be maintained here in order to
get noticed, be of help to new Flutter devs, and have an impact on the
community.

You can maintain your sample app in your own repo (or with another source
control provider) and still be as important a part of the Flutter-verse as
anything you see here. You can let us know on the
[FlutterDev Google Group](https://groups.google.com/forum/#!forum/flutter-dev)
when you've published something and Tweet about it with the
[#flutterio](https://twitter.com/search?q=%23flutterio) hashtag.

## So what should be contributed here, then?

Fixes and necessary improvements to the existing samples, mostly.

## Before you contribute

Before we can use your code, you must sign the
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
Expand All @@ -18,19 +41,19 @@ us first through the issue tracker with your idea so that we can help out and
possibly guide you. Coordinating up front makes it much easier to avoid
frustration later on.

### Code reviews
## Code reviews

All submissions, including submissions by project members, require review.

### File headers
## File headers

All files in the project must start with the following header.

// Copyright 2016 The Chromium Authors. All rights reserved.
// 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.

### The small print
## The small print

Contributions made by corporations are covered by a different agreement than the
one above, the
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Flutter samples

[![Build Status](https://travis-ci.org/flutter/samples.svg?branch=master)](https://travis-ci.org/flutter/samples)

A collection of open source samples that illustrate best practices for
[Flutter](https://flutter.io).

Expand Down
5 changes: 5 additions & 0 deletions jsonexample/lib/built_value/built_complex_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ abstract class BuiltComplexObject
@nullable
double get aDouble;

@nullable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I've literally never noticed this annotation before!

BuiltSimpleObject get anObject;

@nullable
BuiltList<String> get aListOfStrings;

@nullable
BuiltList<int> get aListOfInts;

@nullable
BuiltList<double> get aListOfDoubles;

@nullable
BuiltList<BuiltSimpleObject> get aListOfObjects;

BuiltComplexObject._();
Expand Down
94 changes: 47 additions & 47 deletions jsonexample/lib/built_value/built_complex_object.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
part of 'built_complex_object.dart';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who generates this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from the built_value package. I've managed to double up some commits in this PR. This is from our JSON example app.

// **************************************************************************
// Generator: BuiltValueGenerator
// BuiltValueGenerator
// **************************************************************************

// ignore_for_file: always_put_control_body_on_new_line
Expand All @@ -31,27 +31,7 @@ class _$BuiltComplexObjectSerializer
@override
Iterable serialize(Serializers serializers, BuiltComplexObject object,
{FullType specifiedType: FullType.unspecified}) {
final result = <Object>[
'anObject',
serializers.serialize(object.anObject,
specifiedType: const FullType(BuiltSimpleObject)),
'aListOfStrings',
serializers.serialize(object.aListOfStrings,
specifiedType:
const FullType(BuiltList, const [const FullType(String)])),
'aListOfInts',
serializers.serialize(object.aListOfInts,
specifiedType:
const FullType(BuiltList, const [const FullType(int)])),
'aListOfDoubles',
serializers.serialize(object.aListOfDoubles,
specifiedType:
const FullType(BuiltList, const [const FullType(double)])),
'aListOfObjects',
serializers.serialize(object.aListOfObjects,
specifiedType: const FullType(
BuiltList, const [const FullType(BuiltSimpleObject)])),
];
final result = <Object>[];
if (object.aString != null) {
result
..add('aString')
Expand All @@ -70,6 +50,40 @@ class _$BuiltComplexObjectSerializer
..add(serializers.serialize(object.aDouble,
specifiedType: const FullType(double)));
}
if (object.anObject != null) {
result
..add('anObject')
..add(serializers.serialize(object.anObject,
specifiedType: const FullType(BuiltSimpleObject)));
}
if (object.aListOfStrings != null) {
result
..add('aListOfStrings')
..add(serializers.serialize(object.aListOfStrings,
specifiedType:
const FullType(BuiltList, const [const FullType(String)])));
}
if (object.aListOfInts != null) {
result
..add('aListOfInts')
..add(serializers.serialize(object.aListOfInts,
specifiedType:
const FullType(BuiltList, const [const FullType(int)])));
}
if (object.aListOfDoubles != null) {
result
..add('aListOfDoubles')
..add(serializers.serialize(object.aListOfDoubles,
specifiedType:
const FullType(BuiltList, const [const FullType(double)])));
}
if (object.aListOfObjects != null) {
result
..add('aListOfObjects')
..add(serializers.serialize(object.aListOfObjects,
specifiedType: const FullType(
BuiltList, const [const FullType(BuiltSimpleObject)])));
}

return result;
}
Expand Down Expand Up @@ -163,21 +177,7 @@ class _$BuiltComplexObject extends BuiltComplexObject {
this.aListOfInts,
this.aListOfDoubles,
this.aListOfObjects})
: super._() {
if (anObject == null)
throw new BuiltValueNullFieldError('BuiltComplexObject', 'anObject');
if (aListOfStrings == null)
throw new BuiltValueNullFieldError(
'BuiltComplexObject', 'aListOfStrings');
if (aListOfInts == null)
throw new BuiltValueNullFieldError('BuiltComplexObject', 'aListOfInts');
if (aListOfDoubles == null)
throw new BuiltValueNullFieldError(
'BuiltComplexObject', 'aListOfDoubles');
if (aListOfObjects == null)
throw new BuiltValueNullFieldError(
'BuiltComplexObject', 'aListOfObjects');
}
: super._();

@override
BuiltComplexObject rebuild(void updates(BuiltComplexObjectBuilder b)) =>
Expand Down Expand Up @@ -315,24 +315,24 @@ class BuiltComplexObjectBuilder
aString: aString,
anInt: anInt,
aDouble: aDouble,
anObject: anObject.build(),
aListOfStrings: aListOfStrings.build(),
aListOfInts: aListOfInts.build(),
aListOfDoubles: aListOfDoubles.build(),
aListOfObjects: aListOfObjects.build());
anObject: _anObject?.build(),
aListOfStrings: _aListOfStrings?.build(),
aListOfInts: _aListOfInts?.build(),
aListOfDoubles: _aListOfDoubles?.build(),
aListOfObjects: _aListOfObjects?.build());
} catch (_) {
String _$failedField;
try {
_$failedField = 'anObject';
anObject.build();
_anObject?.build();
_$failedField = 'aListOfStrings';
aListOfStrings.build();
_aListOfStrings?.build();
_$failedField = 'aListOfInts';
aListOfInts.build();
_aListOfInts?.build();
_$failedField = 'aListOfDoubles';
aListOfDoubles.build();
_aListOfDoubles?.build();
_$failedField = 'aListOfObjects';
aListOfObjects.build();
_aListOfObjects?.build();
} catch (e) {
throw new BuiltValueNestedFieldError(
'BuiltComplexObject', _$failedField, e.toString());
Expand Down
3 changes: 3 additions & 0 deletions jsonexample/lib/built_value/built_simple_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ abstract class BuiltSimpleObject
@nullable
double get aDouble;

@nullable
BuiltList<String> get aListOfStrings;

@nullable
BuiltList<int> get aListOfInts;

@nullable
BuiltList<double> get aListOfDoubles;

BuiltSimpleObject._();
Expand Down
59 changes: 30 additions & 29 deletions jsonexample/lib/built_value/built_simple_object.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
part of 'built_simple_object.dart';

// **************************************************************************
// Generator: BuiltValueGenerator
// BuiltValueGenerator
// **************************************************************************

// ignore_for_file: always_put_control_body_on_new_line
Expand All @@ -31,20 +31,7 @@ class _$BuiltSimpleObjectSerializer
@override
Iterable serialize(Serializers serializers, BuiltSimpleObject object,
{FullType specifiedType: FullType.unspecified}) {
final result = <Object>[
'aListOfStrings',
serializers.serialize(object.aListOfStrings,
specifiedType:
const FullType(BuiltList, const [const FullType(String)])),
'aListOfInts',
serializers.serialize(object.aListOfInts,
specifiedType:
const FullType(BuiltList, const [const FullType(int)])),
'aListOfDoubles',
serializers.serialize(object.aListOfDoubles,
specifiedType:
const FullType(BuiltList, const [const FullType(double)])),
];
final result = <Object>[];
if (object.aString != null) {
result
..add('aString')
Expand All @@ -63,6 +50,27 @@ class _$BuiltSimpleObjectSerializer
..add(serializers.serialize(object.aDouble,
specifiedType: const FullType(double)));
}
if (object.aListOfStrings != null) {
result
..add('aListOfStrings')
..add(serializers.serialize(object.aListOfStrings,
specifiedType:
const FullType(BuiltList, const [const FullType(String)])));
}
if (object.aListOfInts != null) {
result
..add('aListOfInts')
..add(serializers.serialize(object.aListOfInts,
specifiedType:
const FullType(BuiltList, const [const FullType(int)])));
}
if (object.aListOfDoubles != null) {
result
..add('aListOfDoubles')
..add(serializers.serialize(object.aListOfDoubles,
specifiedType:
const FullType(BuiltList, const [const FullType(double)])));
}

return result;
}
Expand Down Expand Up @@ -139,14 +147,7 @@ class _$BuiltSimpleObject extends BuiltSimpleObject {
this.aListOfStrings,
this.aListOfInts,
this.aListOfDoubles})
: super._() {
if (aListOfStrings == null)
throw new BuiltValueNullFieldError('BuiltSimpleObject', 'aListOfStrings');
if (aListOfInts == null)
throw new BuiltValueNullFieldError('BuiltSimpleObject', 'aListOfInts');
if (aListOfDoubles == null)
throw new BuiltValueNullFieldError('BuiltSimpleObject', 'aListOfDoubles');
}
: super._();

@override
BuiltSimpleObject rebuild(void updates(BuiltSimpleObjectBuilder b)) =>
Expand Down Expand Up @@ -262,18 +263,18 @@ class BuiltSimpleObjectBuilder
aString: aString,
anInt: anInt,
aDouble: aDouble,
aListOfStrings: aListOfStrings.build(),
aListOfInts: aListOfInts.build(),
aListOfDoubles: aListOfDoubles.build());
aListOfStrings: _aListOfStrings?.build(),
aListOfInts: _aListOfInts?.build(),
aListOfDoubles: _aListOfDoubles?.build());
} catch (_) {
String _$failedField;
try {
_$failedField = 'aListOfStrings';
aListOfStrings.build();
_aListOfStrings?.build();
_$failedField = 'aListOfInts';
aListOfInts.build();
_aListOfInts?.build();
_$failedField = 'aListOfDoubles';
aListOfDoubles.build();
_aListOfDoubles?.build();
} catch (e) {
throw new BuiltValueNestedFieldError(
'BuiltSimpleObject', _$failedField, e.toString());
Expand Down
2 changes: 1 addition & 1 deletion jsonexample/lib/built_value/built_value_serializers.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
part of serializers;

// **************************************************************************
// Generator: BuiltValueGenerator
// BuiltValueGenerator
// **************************************************************************

// ignore_for_file: always_put_control_body_on_new_line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
part of 'serializable_complex_object.dart';

// **************************************************************************
// Generator: JsonSerializableGenerator
// JsonSerializableGenerator
// **************************************************************************

SerializableComplexObject _$SerializableComplexObjectFromJson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
part of 'serializable_simple_object.dart';

// **************************************************************************
// Generator: JsonSerializableGenerator
// JsonSerializableGenerator
// **************************************************************************

SerializableSimpleObject _$SerializableSimpleObjectFromJson(
Expand Down
Loading