1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-09 06:18:49 +00:00

Adjust animations lint rules (#814)

This commit is contained in:
Brett Morgan
2021-06-08 09:00:06 +10:00
committed by GitHub
parent 12ba3b2245
commit b1a49c0afb
28 changed files with 75 additions and 46 deletions

View File

@@ -24,7 +24,7 @@ import 'src/misc/hero_animation.dart';
import 'src/misc/physics_card_drag.dart';
import 'src/misc/repeating_animation.dart';
void main() => runApp(AnimationSamples());
void main() => runApp(const AnimationSamples());
class Demo {
final String name;
@@ -42,42 +42,42 @@ final basicDemos = [
Demo(
name: 'AnimatedContainer',
route: AnimatedContainerDemo.routeName,
builder: (context) => AnimatedContainerDemo()),
builder: (context) => const AnimatedContainerDemo()),
Demo(
name: 'PageRouteBuilder',
route: PageRouteBuilderDemo.routeName,
builder: (context) => PageRouteBuilderDemo()),
builder: (context) => const PageRouteBuilderDemo()),
Demo(
name: 'Animation Controller',
route: AnimationControllerDemo.routeName,
builder: (context) => AnimationControllerDemo()),
builder: (context) => const AnimationControllerDemo()),
Demo(
name: 'Tweens',
route: TweenDemo.routeName,
builder: (context) => TweenDemo()),
builder: (context) => const TweenDemo()),
Demo(
name: 'AnimatedBuilder',
route: AnimatedBuilderDemo.routeName,
builder: (context) => AnimatedBuilderDemo()),
builder: (context) => const AnimatedBuilderDemo()),
Demo(
name: 'Custom Tween',
route: CustomTweenDemo.routeName,
builder: (context) => CustomTweenDemo()),
builder: (context) => const CustomTweenDemo()),
Demo(
name: 'Tween Sequences',
route: TweenSequenceDemo.routeName,
builder: (context) => TweenSequenceDemo()),
builder: (context) => const TweenSequenceDemo()),
Demo(
name: 'Fade Transition',
route: FadeTransitionDemo.routeName,
builder: (context) => FadeTransitionDemo()),
builder: (context) => const FadeTransitionDemo()),
];
final miscDemos = [
Demo(
name: 'Expandable Card',
route: ExpandCardDemo.routeName,
builder: (context) => ExpandCardDemo()),
builder: (context) => const ExpandCardDemo()),
Demo(
name: 'Carousel',
route: CarouselDemo.routeName,
@@ -85,39 +85,39 @@ final miscDemos = [
Demo(
name: 'Focus Image',
route: FocusImageDemo.routeName,
builder: (context) => FocusImageDemo()),
builder: (context) => const FocusImageDemo()),
Demo(
name: 'Card Swipe',
route: CardSwipeDemo.routeName,
builder: (context) => CardSwipeDemo()),
builder: (context) => const CardSwipeDemo()),
Demo(
name: 'Repeating Animation',
route: RepeatingAnimationDemo.routeName,
builder: (context) => RepeatingAnimationDemo()),
builder: (context) => const RepeatingAnimationDemo()),
Demo(
name: 'Spring Physics',
route: PhysicsCardDragDemo.routeName,
builder: (context) => PhysicsCardDragDemo()),
builder: (context) => const PhysicsCardDragDemo()),
Demo(
name: 'AnimatedList',
route: AnimatedListDemo.routeName,
builder: (context) => AnimatedListDemo()),
builder: (context) => const AnimatedListDemo()),
Demo(
name: 'AnimatedPositioned',
route: AnimatedPositionedDemo.routeName,
builder: (context) => AnimatedPositionedDemo()),
builder: (context) => const AnimatedPositionedDemo()),
Demo(
name: 'AnimatedSwitcher',
route: AnimatedSwitcherDemo.routeName,
builder: (context) => AnimatedSwitcherDemo()),
builder: (context) => const AnimatedSwitcherDemo()),
Demo(
name: 'Hero Animation',
route: HeroAnimationDemo.routeName,
builder: (context) => HeroAnimationDemo()),
builder: (context) => const HeroAnimationDemo()),
Demo(
name: 'Curved Animation',
route: CurvedAnimationDemo.routeName,
builder: (context) => CurvedAnimationDemo()),
builder: (context) => const CurvedAnimationDemo()),
];
final basicDemoRoutes =
@@ -132,6 +132,8 @@ final allRoutes = <String, WidgetBuilder>{
};
class AnimationSamples extends StatelessWidget {
const AnimationSamples({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
@@ -140,12 +142,14 @@ class AnimationSamples extends StatelessWidget {
primarySwatch: Colors.deepPurple,
),
routes: allRoutes,
home: HomePage(),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final headerStyle = Theme.of(context).textTheme.headline6;
@@ -156,9 +160,9 @@ class HomePage extends StatelessWidget {
body: ListView(
children: [
ListTile(title: Text('Basics', style: headerStyle)),
...basicDemos.map((d) => DemoTile(d)),
...basicDemos.map((d) => DemoTile(demo: d)),
ListTile(title: Text('Misc', style: headerStyle)),
...miscDemos.map((d) => DemoTile(d)),
...miscDemos.map((d) => DemoTile(demo: d)),
],
),
);
@@ -168,7 +172,7 @@ class HomePage extends StatelessWidget {
class DemoTile extends StatelessWidget {
final Demo demo;
const DemoTile(this.demo);
const DemoTile({required this.demo, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {