mirror of
https://github.com/flutter/samples.git
synced 2026-04-04 18:51:05 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -17,9 +17,10 @@ class _$BuiltComplexObjectSerializer
|
||||
final String wireName = 'BuiltComplexObject';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, BuiltComplexObject object,
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers, BuiltComplexObject object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.aString;
|
||||
if (value != null) {
|
||||
@@ -85,7 +86,7 @@ class _$BuiltComplexObjectSerializer
|
||||
|
||||
@override
|
||||
BuiltComplexObject deserialize(
|
||||
Serializers serializers, Iterable<Object> serialized,
|
||||
Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new BuiltComplexObjectBuilder();
|
||||
|
||||
@@ -93,7 +94,7 @@ class _$BuiltComplexObjectSerializer
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'aString':
|
||||
result.aString = serializers.deserialize(value,
|
||||
@@ -109,31 +110,31 @@ class _$BuiltComplexObjectSerializer
|
||||
break;
|
||||
case 'anObject':
|
||||
result.anObject.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(BuiltSimpleObject))
|
||||
specifiedType: const FullType(BuiltSimpleObject))!
|
||||
as BuiltSimpleObject);
|
||||
break;
|
||||
case 'aListOfStrings':
|
||||
result.aListOfStrings.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)]))
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(String)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'aListOfInts':
|
||||
result.aListOfInts.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(int)]))
|
||||
const FullType(BuiltList, const [const FullType(int)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'aListOfDoubles':
|
||||
result.aListOfDoubles.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(double)]))
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(double)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'aListOfObjects':
|
||||
result.aListOfObjects.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(BuiltSimpleObject)]))
|
||||
BuiltList, const [const FullType(BuiltSimpleObject)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ class _$BuiltSimpleObjectSerializer
|
||||
final String wireName = 'BuiltSimpleObject';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, BuiltSimpleObject object,
|
||||
Iterable<Object?> serialize(Serializers serializers, BuiltSimpleObject object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.aString;
|
||||
if (value != null) {
|
||||
@@ -70,7 +70,7 @@ class _$BuiltSimpleObjectSerializer
|
||||
|
||||
@override
|
||||
BuiltSimpleObject deserialize(
|
||||
Serializers serializers, Iterable<Object> serialized,
|
||||
Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new BuiltSimpleObjectBuilder();
|
||||
|
||||
@@ -78,7 +78,7 @@ class _$BuiltSimpleObjectSerializer
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'aString':
|
||||
result.aString = serializers.deserialize(value,
|
||||
@@ -94,20 +94,20 @@ class _$BuiltSimpleObjectSerializer
|
||||
break;
|
||||
case 'aListOfStrings':
|
||||
result.aListOfStrings.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)]))
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(String)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'aListOfInts':
|
||||
result.aListOfInts.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(int)]))
|
||||
const FullType(BuiltList, const [const FullType(int)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'aListOfDoubles':
|
||||
result.aListOfDoubles.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(double)]))
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(double)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
abstract class JsonStrings {
|
||||
static final String listOfInts = '[1, 2, 3]';
|
||||
static const listOfInts = '[1, 2, 3]';
|
||||
|
||||
static final String listOfDoubles = '[1.0, 2.0, 3.0]';
|
||||
static const listOfDoubles = '[1.0, 2.0, 3.0]';
|
||||
|
||||
static final String listOfStrings = '["one", "two", "three"]';
|
||||
static const listOfStrings = '["one", "two", "three"]';
|
||||
|
||||
static final String listOfDynamics = '[1, "two", 3.0]';
|
||||
static const listOfDynamics = '[1, "two", 3.0]';
|
||||
|
||||
static final String mapOfDynamics = '''
|
||||
static const mapOfDynamics = '''
|
||||
{
|
||||
"anInt": 1,
|
||||
"aString": "Blah, blah, blah.",
|
||||
"aDouble": 1.0
|
||||
}''';
|
||||
|
||||
static final String listOfSimpleObjects = '''
|
||||
static const listOfSimpleObjects = '''
|
||||
[
|
||||
{
|
||||
"aString": "Blah, blah, blah.",
|
||||
@@ -97,7 +97,7 @@ abstract class JsonStrings {
|
||||
]
|
||||
''';
|
||||
|
||||
static final List<String> simpleObjects = [
|
||||
static final simpleObjects = [
|
||||
'''
|
||||
{
|
||||
"aString": "Blah, blah, blah.",
|
||||
@@ -184,7 +184,7 @@ abstract class JsonStrings {
|
||||
}''',
|
||||
];
|
||||
|
||||
static final List<String> complexObjects = [
|
||||
static final complexObjects = [
|
||||
'''
|
||||
{
|
||||
"aString": "Blah, blah, blah.",
|
||||
|
||||
@@ -15,13 +15,13 @@ class MyApp extends StatelessWidget {
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: MyHomePage(),
|
||||
home: const MyHomePage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatelessWidget {
|
||||
MyHomePage({Key? key}) : super(key: key);
|
||||
const MyHomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:jsonexample/utils.dart';
|
||||
|
||||
class SimpleObjectView extends StatelessWidget {
|
||||
SimpleObjectView(dynamic obj) : simpleObject = obj;
|
||||
const SimpleObjectView(this.simpleObject);
|
||||
|
||||
final dynamic simpleObject;
|
||||
|
||||
@@ -93,7 +93,7 @@ class SimpleObjectView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SimpleObjectViewList extends StatelessWidget {
|
||||
SimpleObjectViewList(List<dynamic> objects) : simpleObjects = objects;
|
||||
const SimpleObjectViewList(this.simpleObjects);
|
||||
|
||||
final List<dynamic> simpleObjects;
|
||||
|
||||
@@ -125,7 +125,7 @@ class SimpleObjectViewList extends StatelessWidget {
|
||||
class ComplexObjectView extends StatelessWidget {
|
||||
final dynamic complexObject;
|
||||
|
||||
ComplexObjectView(dynamic obj) : complexObject = obj;
|
||||
const ComplexObjectView(this.complexObject);
|
||||
|
||||
List<Widget> _generateSimpleObjectWidgets(Iterable<dynamic>? simpleObjects) {
|
||||
if (simpleObjects == null) {
|
||||
@@ -267,7 +267,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ComplexObjectViewList extends StatelessWidget {
|
||||
ComplexObjectViewList(List<dynamic> objects) : complexObjects = objects;
|
||||
const ComplexObjectViewList(this.complexObjects);
|
||||
|
||||
final List<dynamic> complexObjects;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user