1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-25 00:18:41 +00:00

Upgrading samples to flutter_lints, part 1 of n (#804)

This commit is contained in:
Brett Morgan
2021-06-05 12:24:28 +10:00
committed by GitHub
parent 14921d0c06
commit 936d1fdaae
230 changed files with 2361 additions and 2444 deletions

View File

@@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart' as url_launcher;
class PolicyDialog extends StatelessWidget {
PolicyDialog({
Key key,
const PolicyDialog({
Key? key,
this.radius = 8,
}) : super(key: key);
@@ -23,7 +23,7 @@ class PolicyDialog extends StatelessWidget {
builder: (context) {
var height = MediaQuery.of(context).size.height;
var width = MediaQuery.of(context).size.width;
return Container(
return SizedBox(
height: height / 4,
width: width / 4,
child: Column(
@@ -41,16 +41,16 @@ class PolicyDialog extends StatelessWidget {
textAlign: TextAlign.left,
text: TextSpan(
text: '',
style: TextStyle(color: Colors.black, fontSize: 18),
style: const TextStyle(color: Colors.black, fontSize: 18),
children: <TextSpan>[
TextSpan(
text: 'https://policies.google.com/terms',
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.lightBlue),
recognizer: TapGestureRecognizer()
..onTap = () async {
final url = 'https://policies.google.com/terms';
const url = 'https://policies.google.com/terms';
if (await url_launcher.canLaunch(url)) {
await url_launcher.launch(url);
}
@@ -63,16 +63,16 @@ class PolicyDialog extends StatelessWidget {
textAlign: TextAlign.left,
text: TextSpan(
text: '',
style: TextStyle(color: Colors.black, fontSize: 18),
style: const TextStyle(color: Colors.black, fontSize: 18),
children: <TextSpan>[
TextSpan(
text: 'https://unsplash.com/terms',
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.lightBlue),
recognizer: TapGestureRecognizer()
..onTap = () async {
final url = 'https://unsplash.com/terms';
const url = 'https://unsplash.com/terms';
if (await url_launcher.canLaunch(url)) {
await url_launcher.launch(url);
}
@@ -93,7 +93,7 @@ class PolicyDialog extends StatelessWidget {
},
child: Text(
'CLOSE'.toUpperCase(),
style: TextStyle(fontSize: 20),
style: const TextStyle(fontSize: 20),
),
),
],

View File

@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:url_launcher/link.dart';
@@ -17,8 +16,8 @@ typedef PhotoDetailsPhotoSaveCallback = void Function(Photo);
class PhotoDetails extends StatefulWidget {
const PhotoDetails({
@required this.photo,
@required this.onPhotoSave,
required this.photo,
required this.onPhotoSave,
});
final Photo photo;
final PhotoDetailsPhotoSaveCallback onPhotoSave;
@@ -32,21 +31,21 @@ class _PhotoDetailsState extends State<PhotoDetails>
Widget _buildPhotoAttribution(BuildContext context) {
return Row(
children: [
Text('Photo by '),
const Text('Photo by '),
Link(
uri: Uri.parse(
'https://unsplash.com/@${widget.photo.user.username}?utm_source=$unsplashAppName&utm_medium=referral'),
'https://unsplash.com/@${widget.photo.user!.username}?utm_source=$unsplashAppName&utm_medium=referral'),
builder: (context, followLink) => TextButton(
onPressed: followLink,
child: Text(widget.photo.user.name),
child: Text(widget.photo.user!.name),
),
),
Text(' on '),
const Text(' on '),
Link(
uri: _unsplashHomepage,
builder: (context, followLink) => TextButton(
onPressed: followLink,
child: Text('Unsplash'),
child: const Text('Unsplash'),
),
),
],
@@ -65,22 +64,22 @@ class _PhotoDetailsState extends State<PhotoDetails>
const SizedBox(height: 16),
Card(
shape: ContinuousRectangleBorder(
side: BorderSide(color: Colors.black12),
side: const BorderSide(color: Colors.black12),
borderRadius: BorderRadius.circular(4),
),
child: AnimatedSize(
vsync: this,
duration: Duration(milliseconds: 750),
duration: const Duration(milliseconds: 750),
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 40),
child: ConstrainedBox(
constraints: BoxConstraints(
constraints: const BoxConstraints(
minWidth: 400,
minHeight: 400,
),
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: widget.photo.urls.small,
image: widget.photo.urls!.small!,
),
),
),
@@ -97,7 +96,7 @@ class _PhotoDetailsState extends State<PhotoDetails>
const SizedBox(width: 8),
IconButton(
visualDensity: VisualDensity.compact,
icon: Icon(Icons.cloud_download),
icon: const Icon(Icons.cloud_download),
onPressed: () => widget.onPhotoSave(widget.photo),
),
],

View File

@@ -24,15 +24,12 @@ import 'package:flutter/material.dart';
class Split extends StatefulWidget {
/// Builds a split oriented along [axis].
const Split({
Key key,
@required this.axis,
@required this.firstChild,
@required this.secondChild,
double initialFirstFraction,
Key? key,
required this.axis,
required this.firstChild,
required this.secondChild,
double? initialFirstFraction,
}) : initialFirstFraction = initialFirstFraction ?? 0.5,
assert(axis != null),
assert(firstChild != null),
assert(secondChild != null),
super(key: key);
/// The main axis the children will lay out on.
@@ -81,7 +78,7 @@ class Split extends StatefulWidget {
}
class _SplitState extends State<Split> {
double firstFraction;
late double firstFraction;
double get secondFraction => 1 - firstFraction;
@@ -111,9 +108,8 @@ class _SplitState extends State<Split> {
var secondSize = axisSize * secondFraction;
// Clamp the sizes to be sure there is enough space for the dividers.
firstSize = firstSize.clamp(halfDivider, axisSize - halfDivider) as double;
secondSize =
secondSize.clamp(halfDivider, axisSize - halfDivider) as double;
firstSize = firstSize.clamp(halfDivider, axisSize - halfDivider);
secondSize = secondSize.clamp(halfDivider, axisSize - halfDivider);
// Remove space from each child to place the divider in the middle.
firstSize = firstSize - halfDivider;
@@ -126,7 +122,7 @@ class _SplitState extends State<Split> {
// Update the fraction of space consumed by the children,
// being sure not to allocate any negative space.
firstFraction += fractionalDelta;
firstFraction = firstFraction.clamp(0.0, 1.0) as double;
firstFraction = firstFraction.clamp(0.0, 1.0);
});
}