1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-06 03:31:03 +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

@@ -49,13 +49,13 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
// and shrinking cards.
return Scaffold(
appBar: AppBar(
title: Text('AnimatedContainer'),
title: const Text('AnimatedContainer'),
),
body: Center(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: 128,
height: 128,
@@ -70,7 +70,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: Text(
child: const Text(
'change',
),
onPressed: () => change(),

View File

@@ -11,11 +11,11 @@ class PageRouteBuilderDemo extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page 1'),
title: const Text('Page 1'),
),
body: Center(
child: ElevatedButton(
child: Text('Go!'),
child: const Text('Go!'),
onPressed: () {
Navigator.of(context).push<void>(_createRoute());
},
@@ -29,7 +29,8 @@ Route _createRoute() {
return PageRouteBuilder<SlideTransition>(
pageBuilder: (context, animation, secondaryAnimation) => _Page2(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
var tween = Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset.zero);
var tween =
Tween<Offset>(begin: const Offset(0.0, 1.0), end: Offset.zero);
var curveTween = CurveTween(curve: Curves.ease);
return SlideTransition(
@@ -45,7 +46,7 @@ class _Page2 extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page 2'),
title: const Text('Page 2'),
),
body: Center(
child: Text('Page 2!', style: Theme.of(context).textTheme.headline4),

View File

@@ -54,22 +54,22 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
// has completed.
return Scaffold(
appBar: AppBar(
title: Text('Animation Controller'),
title: const Text('Animation Controller'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 200),
constraints: const BoxConstraints(maxWidth: 200),
child: Text(
'${controller.value.toStringAsFixed(2)}',
controller.value.toStringAsFixed(2),
style: Theme.of(context).textTheme.headline3,
textScaleFactor: 1 + controller.value,
),
),
ElevatedButton(
child: Text('animate'),
child: const Text('animate'),
onPressed: () {
if (controller.status == AnimationStatus.completed) {
controller.reverse();

View File

@@ -40,16 +40,16 @@ class _TweenDemoState extends State<TweenDemo>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Tweens'),
title: const Text('Tweens'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 200),
constraints: const BoxConstraints(maxWidth: 200),
child: Text('\$${animation.value.toStringAsFixed(2)}',
style: TextStyle(fontSize: 24)),
style: const TextStyle(fontSize: 24)),
),
ElevatedButton(
child: Text(

View File

@@ -15,7 +15,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
with SingleTickerProviderStateMixin {
static const Color beginColor = Colors.deepPurple;
static const Color endColor = Colors.deepOrange;
Duration duration = Duration(milliseconds: 800);
Duration duration = const Duration(milliseconds: 800);
late AnimationController controller;
late Animation<Color?> animation;
@@ -38,7 +38,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AnimatedBuilder'),
title: const Text('AnimatedBuilder'),
),
body: Center(
// AnimatedBuilder handles listening to a given animation and calling the builder
@@ -66,7 +66,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
// if there is a non-animated Widget contained within the animated widget.
// This can improve performance since this widget doesn't need to be rebuilt
// when the animation changes.
child: Text(
child: const Text(
'Change Color',
style: TextStyle(color: Colors.white),
),

View File

@@ -47,7 +47,7 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Custom Tween'),
title: const Text('Custom Tween'),
actions: [
MaterialButton(
child: Text(
@@ -79,16 +79,18 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8.0),
child: Card(
child: Container(
padding: EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8.0),
child: AnimatedBuilder(
animation: animation,
builder: (context, child) {
return Text('${animation.value}',
style: TextStyle(
fontSize: 16, fontFamily: 'SpecialElite'));
return Text(
animation.value,
style: const TextStyle(
fontSize: 16, fontFamily: 'SpecialElite'),
);
},
),
),

View File

@@ -60,7 +60,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Tween Sequences'),
title: const Text('Tween Sequences'),
),
body: Center(
child: AnimatedBuilder(
@@ -75,7 +75,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
child: child,
);
},
child: Text('Animate', style: TextStyle(color: Colors.white)),
child: const Text('Animate', style: TextStyle(color: Colors.white)),
),
),
);

View File

@@ -24,7 +24,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 500),
duration: const Duration(milliseconds: 500),
);
_curve = CurvedAnimation(parent: _controller, curve: Curves.easeIn);
@@ -45,7 +45,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
title: const Text(
'Fade Transition',
),
),
@@ -55,14 +55,14 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
children: <Widget>[
FadeTransition(
opacity: _animation,
child: Icon(
child: const Icon(
Icons.star,
color: Colors.amber,
size: 300,
),
),
ElevatedButton(
child: Text('animate'),
child: const Text('animate'),
onPressed: () => setState(() {
_controller.animateTo(1.0).then<TickerFuture>(
(value) => _controller.animateBack(0.0));