mirror of
https://github.com/flutter/samples.git
synced 2026-03-31 16:55:34 +00:00
jsonexample: Update lint rules, rebuild runners (#826)
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jsonexample/tab_pages.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
@@ -46,7 +48,7 @@ class MyHomePage extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
body: const SafeArea(
|
||||
bottom: false,
|
||||
child: TabBarView(
|
||||
children: [
|
||||
|
||||
@@ -17,6 +17,8 @@ import 'package:jsonexample/utils.dart';
|
||||
import 'package:jsonexample/widgets.dart';
|
||||
|
||||
class BasicsPage extends StatelessWidget {
|
||||
const BasicsPage({Key? key}) : super(key: key);
|
||||
|
||||
List<TableRow> createMapRows(
|
||||
Map<String, dynamic> values, TextStyle normalStyle, TextStyle boldStyle) {
|
||||
return values.keys.map((k) {
|
||||
@@ -145,6 +147,8 @@ class BasicsPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ConvertedSimplePage extends StatelessWidget {
|
||||
const ConvertedSimplePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.simpleObjects.map(
|
||||
@@ -158,7 +162,7 @@ class ConvertedSimplePage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
SimpleObjectViewList(objects),
|
||||
SimpleObjectViewList(simpleObjects: objects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -166,6 +170,8 @@ class ConvertedSimplePage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ConvertedComplexPage extends StatelessWidget {
|
||||
const ConvertedComplexPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.complexObjects.map(
|
||||
@@ -179,7 +185,7 @@ class ConvertedComplexPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
ComplexObjectViewList(objects),
|
||||
ComplexObjectViewList(complexObjects: objects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -187,6 +193,8 @@ class ConvertedComplexPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ConvertedListPage extends StatelessWidget {
|
||||
const ConvertedListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final parsedJson = json.decode(JsonStrings.listOfSimpleObjects) as List;
|
||||
@@ -200,7 +208,7 @@ class ConvertedListPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
SimpleObjectViewList(listOfObjects),
|
||||
SimpleObjectViewList(simpleObjects: listOfObjects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -208,6 +216,8 @@ class ConvertedListPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SerializableSimplePage extends StatelessWidget {
|
||||
const SerializableSimplePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.simpleObjects.map(
|
||||
@@ -221,7 +231,7 @@ class SerializableSimplePage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
SimpleObjectViewList(objects),
|
||||
SimpleObjectViewList(simpleObjects: objects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -229,6 +239,8 @@ class SerializableSimplePage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SerializableComplexPage extends StatelessWidget {
|
||||
const SerializableComplexPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.complexObjects.map(
|
||||
@@ -242,7 +254,7 @@ class SerializableComplexPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
ComplexObjectViewList(objects),
|
||||
ComplexObjectViewList(complexObjects: objects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -250,6 +262,8 @@ class SerializableComplexPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SerializableListPage extends StatelessWidget {
|
||||
const SerializableListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final parsedJson = json.decode(JsonStrings.listOfSimpleObjects) as List;
|
||||
@@ -263,7 +277,7 @@ class SerializableListPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
SimpleObjectViewList(listOfObjects),
|
||||
SimpleObjectViewList(simpleObjects: listOfObjects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -271,6 +285,8 @@ class SerializableListPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class BuiltSimplePage extends StatelessWidget {
|
||||
const BuiltSimplePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.simpleObjects.map(
|
||||
@@ -285,7 +301,7 @@ class BuiltSimplePage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
SimpleObjectViewList(objects),
|
||||
SimpleObjectViewList(simpleObjects: objects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -293,6 +309,8 @@ class BuiltSimplePage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class BuiltComplexPage extends StatelessWidget {
|
||||
const BuiltComplexPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.complexObjects.map(
|
||||
@@ -307,7 +325,7 @@ class BuiltComplexPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
ComplexObjectViewList(objects),
|
||||
ComplexObjectViewList(complexObjects: objects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
@@ -315,6 +333,8 @@ class BuiltComplexPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class BuiltListPage extends StatelessWidget {
|
||||
const BuiltListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final parsedJson = json.decode(JsonStrings.listOfSimpleObjects) as List;
|
||||
@@ -329,7 +349,7 @@ class BuiltListPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: [
|
||||
const SizedBox(height: 16.0),
|
||||
SimpleObjectViewList(listOfObjects),
|
||||
SimpleObjectViewList(simpleObjects: listOfObjects),
|
||||
const SizedBox(height: 16.0),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -6,7 +6,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:jsonexample/utils.dart';
|
||||
|
||||
class SimpleObjectView extends StatelessWidget {
|
||||
const SimpleObjectView(this.simpleObject);
|
||||
const SimpleObjectView({required this.simpleObject, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final dynamic simpleObject;
|
||||
|
||||
@@ -93,7 +94,8 @@ class SimpleObjectView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SimpleObjectViewList extends StatelessWidget {
|
||||
const SimpleObjectViewList(this.simpleObjects);
|
||||
const SimpleObjectViewList({required this.simpleObjects, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final List<dynamic> simpleObjects;
|
||||
|
||||
@@ -108,7 +110,7 @@ class SimpleObjectViewList extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
const SizedBox(height: 4.0),
|
||||
SimpleObjectView(simpleObjects[i]),
|
||||
SimpleObjectView(simpleObject: simpleObjects[i]),
|
||||
const SizedBox(height: 24.0),
|
||||
]);
|
||||
}
|
||||
@@ -125,7 +127,8 @@ class SimpleObjectViewList extends StatelessWidget {
|
||||
class ComplexObjectView extends StatelessWidget {
|
||||
final dynamic complexObject;
|
||||
|
||||
const ComplexObjectView(this.complexObject);
|
||||
const ComplexObjectView({required this.complexObject, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
List<Widget> _generateSimpleObjectWidgets(Iterable<dynamic>? simpleObjects) {
|
||||
if (simpleObjects == null) {
|
||||
@@ -149,7 +152,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
return simpleObjects
|
||||
.expand((dynamic o) => [
|
||||
const SizedBox(height: 4.0),
|
||||
SimpleObjectView(o),
|
||||
SimpleObjectView(simpleObject: o),
|
||||
const SizedBox(height: 4.0),
|
||||
])
|
||||
.toList();
|
||||
@@ -204,7 +207,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24.0, 4.0, 0.0, 4.0),
|
||||
child: SimpleObjectView(complexObject.anObject),
|
||||
child: SimpleObjectView(simpleObject: complexObject.anObject),
|
||||
),
|
||||
Table(
|
||||
columnWidths: const {
|
||||
@@ -267,7 +270,8 @@ class ComplexObjectView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ComplexObjectViewList extends StatelessWidget {
|
||||
const ComplexObjectViewList(this.complexObjects);
|
||||
const ComplexObjectViewList({required this.complexObjects, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final List<dynamic> complexObjects;
|
||||
|
||||
@@ -282,7 +286,7 @@ class ComplexObjectViewList extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
const SizedBox(height: 4.0),
|
||||
ComplexObjectView(complexObjects[i]),
|
||||
ComplexObjectView(complexObject: complexObjects[i]),
|
||||
const SizedBox(height: 24.0),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user