mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Remove unneeded types (#949)
This commit is contained in:
@@ -18,7 +18,7 @@ class Book {
|
||||
Thumbnail? thumbnail;
|
||||
|
||||
Object encode() {
|
||||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
|
||||
final pigeonMap = <Object?, Object?>{};
|
||||
pigeonMap['title'] = title;
|
||||
pigeonMap['subtitle'] = subtitle;
|
||||
pigeonMap['author'] = author;
|
||||
@@ -30,7 +30,7 @@ class Book {
|
||||
}
|
||||
|
||||
static Book decode(Object message) {
|
||||
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
|
||||
final pigeonMap = message as Map<Object?, Object?>;
|
||||
return Book()
|
||||
..title = pigeonMap['title'] as String?
|
||||
..subtitle = pigeonMap['subtitle'] as String?
|
||||
@@ -48,13 +48,13 @@ class Thumbnail {
|
||||
String? url;
|
||||
|
||||
Object encode() {
|
||||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
|
||||
final pigeonMap = <Object?, Object?>{};
|
||||
pigeonMap['url'] = url;
|
||||
return pigeonMap;
|
||||
}
|
||||
|
||||
static Thumbnail decode(Object message) {
|
||||
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
|
||||
final pigeonMap = message as Map<Object?, Object?>;
|
||||
return Thumbnail()..url = pigeonMap['url'] as String?;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ abstract class FlutterBookApi {
|
||||
void displayBookDetails(Book book);
|
||||
static void setup(FlutterBookApi? api) {
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
const channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.FlutterBookApi.displayBookDetails', codec);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
@@ -146,7 +146,7 @@ class HostBookApi {
|
||||
static const MessageCodec<Object?> codec = _HostBookApiCodec();
|
||||
|
||||
Future<void> cancel() async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
final channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.HostBookApi.cancel', codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final Map<Object?, Object?>? replyMap =
|
||||
@@ -158,8 +158,7 @@ class HostBookApi {
|
||||
details: null,
|
||||
);
|
||||
} else if (replyMap['error'] != null) {
|
||||
final Map<Object?, Object?> error =
|
||||
(replyMap['error'] as Map<Object?, Object?>?)!;
|
||||
final error = (replyMap['error'] as Map<Object?, Object?>?)!;
|
||||
throw PlatformException(
|
||||
code: (error['code'] as String?)!,
|
||||
message: error['message'] as String?,
|
||||
|
||||
@@ -73,7 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
const Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
|
||||
@@ -59,7 +59,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 42, bottom: 250),
|
||||
child: Align(
|
||||
|
||||
@@ -53,7 +53,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
FadeTransition(
|
||||
opacity: _animation,
|
||||
child: const Icon(
|
||||
|
||||
@@ -78,7 +78,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('AnimatedList'),
|
||||
actions: <Widget>[
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: addUser,
|
||||
|
||||
@@ -42,11 +42,11 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Expanded(
|
||||
child: ClipRect(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
children: [
|
||||
for (final fileName in fileNames)
|
||||
SwipeableCard(
|
||||
imageAssetName: fileName,
|
||||
|
||||
@@ -115,7 +115,7 @@ class UnsplashHomePage extends StatelessWidget {
|
||||
onPhotoSave: (photo) async {
|
||||
final path = await getSavePath(
|
||||
suggestedName: '${photo.id}.jpg',
|
||||
acceptedTypeGroups: <XTypeGroup>[
|
||||
acceptedTypeGroups: [
|
||||
XTypeGroup(
|
||||
label: 'JPG',
|
||||
extensions: ['jpg'],
|
||||
|
||||
@@ -42,7 +42,7 @@ class PolicyDialog extends StatelessWidget {
|
||||
text: TextSpan(
|
||||
text: '• ',
|
||||
style: const TextStyle(color: Colors.black, fontSize: 18),
|
||||
children: <TextSpan>[
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'https://policies.google.com/terms',
|
||||
style: const TextStyle(
|
||||
@@ -64,7 +64,7 @@ class PolicyDialog extends StatelessWidget {
|
||||
text: TextSpan(
|
||||
text: '• ',
|
||||
style: const TextStyle(color: Colors.black, fontSize: 18),
|
||||
children: <TextSpan>[
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'https://unsplash.com/terms',
|
||||
style: const TextStyle(
|
||||
@@ -86,7 +86,7 @@ class PolicyDialog extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: <Widget>[
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@@ -49,7 +49,7 @@ class _PhotoSearchDialogState extends State<PhotoSearchDialog> {
|
||||
}
|
||||
},
|
||||
),
|
||||
actions: <Widget>[
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@@ -17,7 +17,7 @@ class NewCategoryDialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return const SimpleDialog(
|
||||
title: Text('New Category'),
|
||||
children: <Widget>[
|
||||
children: [
|
||||
NewCategoryForm(),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ class _NewEntryFormState extends State<NewEntryForm> {
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: CategoryDropdown(
|
||||
|
||||
@@ -65,7 +65,7 @@ class _AutofillDemoState extends State<AutofillDemo> {
|
||||
hintText: '(123) 456-7890',
|
||||
labelText: 'Telephone',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.telephoneNumber],
|
||||
autofillHints: [AutofillHints.telephoneNumber],
|
||||
),
|
||||
const TextField(
|
||||
keyboardType: TextInputType.streetAddress,
|
||||
@@ -74,7 +74,7 @@ class _AutofillDemoState extends State<AutofillDemo> {
|
||||
hintText: '123 4th Ave',
|
||||
labelText: 'Street Address',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.streetAddressLine1],
|
||||
autofillHints: [AutofillHints.streetAddressLine1],
|
||||
),
|
||||
const TextField(
|
||||
keyboardType: TextInputType.number,
|
||||
@@ -83,7 +83,7 @@ class _AutofillDemoState extends State<AutofillDemo> {
|
||||
hintText: '12345',
|
||||
labelText: 'Postal Code',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.postalCode],
|
||||
autofillHints: [AutofillHints.postalCode],
|
||||
),
|
||||
const TextField(
|
||||
textInputAction: TextInputAction.next,
|
||||
@@ -91,7 +91,7 @@ class _AutofillDemoState extends State<AutofillDemo> {
|
||||
hintText: 'United States',
|
||||
labelText: 'Country',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.countryName],
|
||||
autofillHints: [AutofillHints.countryName],
|
||||
),
|
||||
const TextField(
|
||||
keyboardType: TextInputType.number,
|
||||
@@ -99,7 +99,7 @@ class _AutofillDemoState extends State<AutofillDemo> {
|
||||
hintText: '1',
|
||||
labelText: 'Country Code',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.countryCode],
|
||||
autofillHints: [AutofillHints.countryCode],
|
||||
),
|
||||
].expand(
|
||||
(widget) => [
|
||||
|
||||
@@ -43,7 +43,7 @@ class _DemoState extends State<Demo> {
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Text(deviceInfo),
|
||||
const Padding(padding: EdgeInsets.only(top: 18)),
|
||||
const FlutterLogo(size: 128),
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:jsonexample/dart_convert/converted_simple_object.dart';
|
||||
import 'package:jsonexample/json_serializable/serializable_simple_object.dart';
|
||||
|
||||
void main() {
|
||||
const typicalObjectJson = <String, dynamic>{
|
||||
const typicalObjectJson = {
|
||||
'aString': 'Blah, blah, blah.',
|
||||
'anInt': 1,
|
||||
'aDouble': 1.0,
|
||||
@@ -20,7 +20,7 @@ void main() {
|
||||
'aListOfDoubles': [1.0, 2.0, 3.0]
|
||||
};
|
||||
|
||||
const emptyListJson = <String, dynamic>{
|
||||
const emptyListJson = {
|
||||
'aString': 'Blah, blah, blah.',
|
||||
'anInt': 1,
|
||||
'aDouble': 1.0,
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
'aListOfDoubles': <double>[]
|
||||
};
|
||||
|
||||
const unexpectedPropertiesJson = <String, dynamic>{
|
||||
const unexpectedPropertiesJson = {
|
||||
'aString': 'Blah, blah, blah.',
|
||||
'anInt': 1,
|
||||
'aDouble': 1.0,
|
||||
|
||||
@@ -145,7 +145,7 @@ class StubData {
|
||||
),
|
||||
];
|
||||
|
||||
static const reviewStrings = <String>[
|
||||
static const reviewStrings = [
|
||||
'My favorite place in Portland. The employees are wonderful and so is the food. I go here at least once a month!',
|
||||
'Staff was very friendly. Great atmosphere and good music. Would recommend.',
|
||||
'Best. Place. In. Town. Period.'
|
||||
|
||||
@@ -25,7 +25,7 @@ class _AddPetDetailsState extends State<AddPetDetails> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Add Pet Details'),
|
||||
actions: <Widget>[
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
|
||||
@@ -63,7 +63,7 @@ class MyHomePage extends StatelessWidget {
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
const Text('You have pushed the button this many times:'),
|
||||
// Consumer looks for an ancestor Provider widget
|
||||
// and retrieves its model (Counter, in this case).
|
||||
|
||||
@@ -17,7 +17,7 @@ class HomePage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Testing Sample'),
|
||||
actions: <Widget>[
|
||||
actions: [
|
||||
TextButton.icon(
|
||||
style: TextButton.styleFrom(primary: Colors.white),
|
||||
onPressed: () {
|
||||
|
||||
@@ -174,7 +174,7 @@ class InfoView extends StatelessWidget {
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
FutureBuilder<Set<VeggieCategory>>(
|
||||
future: prefs.preferredCategories,
|
||||
builder: (context, snapshot) {
|
||||
|
||||
@@ -233,7 +233,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
content: const Text(
|
||||
'Are you sure you want to reset the current settings?',
|
||||
),
|
||||
actions: <Widget>[
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
child: const Text('Yes'),
|
||||
@@ -266,7 +266,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
Styles.scaffoldBackground(CupertinoTheme.brightnessOf(context)),
|
||||
child: CustomScrollView(
|
||||
restorationId: 'list',
|
||||
slivers: <Widget>[
|
||||
slivers: [
|
||||
const CupertinoSliverNavigationBar(
|
||||
largeTitle: Text('Settings'),
|
||||
),
|
||||
@@ -274,7 +274,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
top: false,
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
<Widget>[
|
||||
[
|
||||
SettingsGroup(
|
||||
items: [
|
||||
_buildCaloriesItem(context, prefs),
|
||||
|
||||
@@ -130,7 +130,7 @@ class SettingsItemState extends State<SettingsItem> {
|
||||
child: widget.subtitle != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
const SizedBox(height: 8.5),
|
||||
Text(widget.label,
|
||||
style: themeData.textTheme.textStyle),
|
||||
|
||||
@@ -122,7 +122,7 @@ class VeggieCard extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Text(
|
||||
veggie.name,
|
||||
style: Styles.cardTitleText(themeData),
|
||||
|
||||
@@ -153,7 +153,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget {
|
||||
primaryMeasureAxis: const charts.NumericAxisSpec(
|
||||
tickProviderSpec: charts.StaticNumericTickProviderSpec(
|
||||
// Create the ticks to be used the domain axis.
|
||||
<charts.TickSpec<num>>[
|
||||
[
|
||||
charts.TickSpec(0, label: ''),
|
||||
charts.TickSpec(1, label: ''),
|
||||
charts.TickSpec(2, label: ''),
|
||||
|
||||
@@ -81,7 +81,7 @@ class StaticallyProvidedTicks extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Create the ticks to be used the domain axis.
|
||||
final staticTicks = <charts.TickSpec<String>>[
|
||||
final staticTicks = [
|
||||
const charts.TickSpec(
|
||||
// Value must match the domain value.
|
||||
'2014',
|
||||
|
||||
@@ -29,7 +29,7 @@ class GalleryDrawer extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(children: <Widget>[
|
||||
child: ListView(children: [
|
||||
// Performance overlay toggle.
|
||||
ListTile(
|
||||
leading: const Icon(Icons.assessment),
|
||||
|
||||
@@ -57,7 +57,7 @@ class _GalleryScaffoldState extends State<GalleryScaffold> {
|
||||
appBar: AppBar(title: Text(widget.title)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(children: <Widget>[
|
||||
child: Column(children: [
|
||||
SizedBox(height: 250.0, child: widget.childBuilder()),
|
||||
])),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
|
||||
@@ -60,7 +60,7 @@ class CatmullInterpolator implements Interpolator {
|
||||
}
|
||||
|
||||
static void test() {
|
||||
List<Point2D> controlPoints = <Point2D>[];
|
||||
final controlPoints = <Point2D>[];
|
||||
controlPoints.add(Point2D(-1, 1));
|
||||
controlPoints.add(Point2D(0, 1));
|
||||
controlPoints.add(Point2D(1, -1));
|
||||
|
||||
@@ -49,9 +49,9 @@ class LayeredChartState extends State<LayeredChart> {
|
||||
graphHeight = MathUtils.clampedMap(screenRatio, 0.5, 2.5, 50, 150);
|
||||
|
||||
int m = dataToPlot.length;
|
||||
paths = <Path>[];
|
||||
capPaths = <Path>[];
|
||||
maxValues = <double>[];
|
||||
paths = [];
|
||||
capPaths = [];
|
||||
maxValues = [];
|
||||
for (int i = 0; i < m; i++) {
|
||||
int n = dataToPlot[i].series.length;
|
||||
maxValues.add(0);
|
||||
@@ -71,11 +71,11 @@ class LayeredChartState extends State<LayeredChart> {
|
||||
double xWidth = (endX - startX) / numPoints;
|
||||
double capRangeX = capSize * cos(capTheta);
|
||||
double tanCapTheta = tan(capTheta);
|
||||
List<double> curvePoints = <double>[];
|
||||
final curvePoints = <double>[];
|
||||
for (int i = 0; i < m; i++) {
|
||||
List<int> series = dataToPlot[i].series;
|
||||
int n = series.length;
|
||||
List<Point2D> controlPoints = <Point2D>[];
|
||||
final controlPoints = <Point2D>[];
|
||||
controlPoints.add(Point2D(-1, 0));
|
||||
double last = 0;
|
||||
for (int j = 0; j < n; j++) {
|
||||
@@ -135,7 +135,7 @@ class LayeredChartState extends State<LayeredChart> {
|
||||
capPaths[i].lineTo(startX, startY + 1);
|
||||
capPaths[i].close();
|
||||
}
|
||||
labelPainter = <TextPainter>[];
|
||||
labelPainter = [];
|
||||
for (int i = 0; i < dataToPlot.length; i++) {
|
||||
TextSpan span = TextSpan(
|
||||
style: const TextStyle(
|
||||
@@ -148,7 +148,7 @@ class LayeredChartState extends State<LayeredChart> {
|
||||
tp.layout();
|
||||
labelPainter.add(tp);
|
||||
}
|
||||
milestonePainter = <TextPainter>[];
|
||||
milestonePainter = [];
|
||||
for (int i = 0; i < milestones.length; i++) {
|
||||
TextSpan span = TextSpan(
|
||||
style: const TextStyle(
|
||||
|
||||
@@ -48,7 +48,7 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
||||
|
||||
createAnimation(0);
|
||||
|
||||
weekLabels = <WeekLabel>[];
|
||||
weekLabels = [];
|
||||
weekLabels.add(WeekLabel.forDate(DateTime(2019, 2, 26), 'v1.2'));
|
||||
weekLabels.add(WeekLabel.forDate(DateTime(2018, 12, 4), 'v1.0'));
|
||||
// weekLabels.add(WeekLabel.forDate(new DateTime(2018, 9, 19), "Preview 2"));
|
||||
@@ -155,7 +155,7 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
||||
Column mainColumn = Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Expanded(child: layeredChart),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
|
||||
@@ -20,7 +20,7 @@ class ParticleBackgroundPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Positioned.fill(child: AnimatedBackground()),
|
||||
Positioned.fill(child: Particles(30)),
|
||||
Positioned.fill(child: CenteredText()),
|
||||
|
||||
Reference in New Issue
Block a user