Add analysis_options, format and fix up (#104)

pull/109/head
Brett Morgan 6 years ago committed by GitHub
parent bd9b18c2bf
commit 52d85c793e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,32 @@
include: package:pedantic/analysis_options.yaml
analyzer:
exclude:
- lib/json_serializable/*.g.dart
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
- avoid_types_on_closure_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- close_sinks
- constant_identifier_names
- control_flow_in_finally
- empty_statements
- hash_and_equals
- implementation_imports
- non_constant_identifier_names
- package_api_docs
- package_names
- package_prefixed_library_names
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_new
- unnecessary_statements

@ -40,6 +40,7 @@ abstract class BuiltComplexObject
BuiltComplexObject._();
factory BuiltComplexObject([updates(BuiltComplexObjectBuilder b)]) =
factory BuiltComplexObject(
[void Function(BuiltComplexObjectBuilder) updates]) =
_$BuiltComplexObject;
}

@ -33,6 +33,6 @@ abstract class BuiltSimpleObject
BuiltSimpleObject._();
factory BuiltSimpleObject([updates(BuiltSimpleObjectBuilder b)]) =
factory BuiltSimpleObject([void Function(BuiltSimpleObjectBuilder) updates]) =
_$BuiltSimpleObject;
}

@ -29,24 +29,27 @@ class ConvertedComplexObject {
if (json == null) return null;
return ConvertedComplexObject(
aString: json['aString'],
anInt: json['anInt'],
aDouble: json['aDouble'],
aString: json['aString'] as String,
anInt: json['anInt'] as int,
aDouble: json['aDouble'] as double,
anObject: json['anObject'] != null
? ConvertedSimpleObject.fromJson(json['anObject'])
? ConvertedSimpleObject.fromJson(
json['anObject'] as Map<String, dynamic>)
: null,
aListOfStrings: json['aListOfStrings'] != null
? List<String>.from(json['aListOfStrings'])
? List<String>.from(json['aListOfStrings'] as Iterable<dynamic>)
: null,
aListOfInts: json['aListOfInts'] != null
? List<int>.from(json['aListOfInts'])
? List<int>.from(json['aListOfInts'] as Iterable<dynamic>)
: null,
aListOfDoubles: json['aListOfDoubles'] != null
? List<double>.from(json['aListOfDoubles'])
? List<double>.from(json['aListOfDoubles'] as Iterable<dynamic>)
: null,
aListOfObjects: json['aListOfObjects'] != null
? List<ConvertedSimpleObject>.from(json['aListOfObjects']
.map((o) => ConvertedSimpleObject.fromJson(o)))
? List<ConvertedSimpleObject>.from((json['aListOfObjects']
as Iterable<dynamic>)
.map<dynamic>((dynamic o) =>
ConvertedSimpleObject.fromJson(o as Map<String, dynamic>)))
: null);
}
}

@ -23,17 +23,17 @@ class ConvertedSimpleObject {
if (json == null) return null;
return ConvertedSimpleObject(
aString: json['aString'],
anInt: json['anInt'],
aDouble: json['aDouble'],
aString: json['aString'] as String,
anInt: json['anInt'] as int,
aDouble: json['aDouble'] as double,
aListOfStrings: json['aListOfStrings'] != null
? List<String>.from(json['aListOfStrings'])
? List<String>.from(json['aListOfStrings'] as Iterable<dynamic>)
: null,
aListOfInts: json['aListOfInts'] != null
? List<int>.from(json['aListOfInts'])
? List<int>.from(json['aListOfInts'] as Iterable<dynamic>)
: null,
aListOfDoubles: json['aListOfDoubles'] != null
? List<double>.from(json['aListOfDoubles'])
? List<double>.from(json['aListOfDoubles'] as Iterable<dynamic>)
: null,
);
}

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: argument_type_not_assignable, strong_mode_implicit_dynamic_parameter, strong_mode_implicit_dynamic_variable
import 'dart:convert';
import 'package:flutter/material.dart';

@ -58,7 +58,7 @@ class SimpleObjectView extends StatelessWidget {
Text('aListOfStrings:', style: boldStyle),
Text(
prettyPrintList(
simpleObject.aListOfStrings,
simpleObject.aListOfStrings as Iterable<dynamic>,
),
style: localTheme.body1,
),
@ -68,7 +68,7 @@ class SimpleObjectView extends StatelessWidget {
children: [
Text('aListOfInts:', style: boldStyle),
Text(
prettyPrintList(simpleObject.aListOfInts),
prettyPrintList(simpleObject.aListOfInts as Iterable<dynamic>),
style: localTheme.body1,
),
],
@ -80,7 +80,7 @@ class SimpleObjectView extends StatelessWidget {
child: Text('aListOfDoubles:', style: boldStyle),
),
Text(
prettyPrintList(simpleObject.aListOfDoubles),
prettyPrintList(simpleObject.aListOfDoubles as Iterable<dynamic>),
style: localTheme.body1,
),
],
@ -135,7 +135,7 @@ class ComplexObjectView extends StatelessWidget {
];
}
if (simpleObjects.length == 0) {
if (simpleObjects.isEmpty) {
return [
const Padding(
padding: EdgeInsets.symmetric(vertical: 4.0),
@ -145,7 +145,7 @@ class ComplexObjectView extends StatelessWidget {
}
return simpleObjects
.expand((o) => [
.expand((dynamic o) => [
const SizedBox(height: 4.0),
SimpleObjectView(o),
const SizedBox(height: 4.0),
@ -213,7 +213,8 @@ class ComplexObjectView extends StatelessWidget {
children: [
Text('aListOfStrings:', style: boldStyle),
Text(
prettyPrintList(complexObject.aListOfStrings),
prettyPrintList(
complexObject.aListOfStrings as Iterable<dynamic>),
style: localTheme.body1,
),
],
@ -222,7 +223,8 @@ class ComplexObjectView extends StatelessWidget {
children: [
Text('aListOfInts:', style: boldStyle),
Text(
prettyPrintList(complexObject.aListOfInts),
prettyPrintList(
complexObject.aListOfInts as Iterable<dynamic>),
style: localTheme.body1,
),
],
@ -234,7 +236,8 @@ class ComplexObjectView extends StatelessWidget {
child: Text('aListOfDoubles:', style: boldStyle),
),
Text(
prettyPrintList(complexObject.aListOfDoubles),
prettyPrintList(
complexObject.aListOfDoubles as Iterable<dynamic>),
style: localTheme.body1,
),
],
@ -251,8 +254,8 @@ class ComplexObjectView extends StatelessWidget {
padding: const EdgeInsets.only(left: 24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children:
_generateSimpleObjectWidgets(complexObject.aListOfObjects),
children: _generateSimpleObjectWidgets(
complexObject.aListOfObjects as Iterable<dynamic>),
),
),
],

@ -28,7 +28,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
boolean_selector:
dependency: transitive
description:
@ -299,7 +299,7 @@ packages:
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
@ -332,7 +332,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
shelf:
dependency: transitive
description:
@ -407,7 +407,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
version: "0.2.5"
timing:
dependency: transitive
description:

@ -16,6 +16,7 @@ dev_dependencies:
build_runner: ^1.0.0
built_value_generator: ^6.1.5
json_serializable: ^2.2.1
pedantic: ^1.5.0
flutter_test:
sdk: flutter

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: strong_mode_implicit_dynamic_list_literal
import 'package:flutter_test/flutter_test.dart';
import 'package:jsonexample/built_value/built_simple_object.dart';
import 'package:jsonexample/built_value/built_value_serializers.dart';

@ -10,8 +10,7 @@ import 'package:jsonexample/widgets.dart';
void main() {
group('SimpleObjectView widget test', () {
testWidgets('Typical object is displayed correctly',
(WidgetTester tester) async {
testWidgets('Typical object is displayed correctly', (tester) async {
final simpleObject = ConvertedSimpleObject(
aString: 'Blah, blah, blah',
anInt: 1,
@ -35,8 +34,7 @@ void main() {
expect(find.text('[1.0, 2.0, 3.0]'), findsOneWidget);
});
testWidgets('Empty lists are displayed as brackets',
(WidgetTester tester) async {
testWidgets('Empty lists are displayed as brackets', (tester) async {
final simpleObject = ConvertedSimpleObject(
aString: 'Blah, blah, blah',
anInt: 1,
@ -55,8 +53,7 @@ void main() {
expect(find.text('[]'), findsNWidgets(3));
});
testWidgets('Null values are displayed as NULL',
(WidgetTester tester) async {
testWidgets('Null values are displayed as NULL', (tester) async {
final simpleObject = ConvertedSimpleObject(
aString: null,
anInt: null,
@ -77,8 +74,7 @@ void main() {
});
group('ComplexObjectView widget test', () {
testWidgets('Typical object is displayed correctly',
(WidgetTester tester) async {
testWidgets('Typical object is displayed correctly', (tester) async {
final complexObject = ConvertedComplexObject(
aString: 'Blah, blah, blah',
anInt: 1,
@ -145,8 +141,7 @@ void main() {
}
});
testWidgets('Empty lists are displayed as brackets',
(WidgetTester tester) async {
testWidgets('Empty lists are displayed as brackets', (tester) async {
final complexObject = ConvertedComplexObject(
aString: 'Blah, blah, blah',
anInt: 1,
@ -174,8 +169,7 @@ void main() {
expect(find.text('[]'), findsNWidgets(4));
});
testWidgets('Null values are displayed as NULL',
(WidgetTester tester) async {
testWidgets('Null values are displayed as NULL', (tester) async {
final complexObject = ConvertedComplexObject(
aString: null,
anInt: null,

Loading…
Cancel
Save