mirror of
https://github.com/flutter/samples.git
synced 2026-04-03 02:02:27 +00:00
Adjust animations lint rules (#814)
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class AnimatedListDemo extends StatefulWidget {
|
||||
const AnimatedListDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/misc/animated_list';
|
||||
|
||||
@override
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AnimatedPositionedDemo extends StatefulWidget {
|
||||
const AnimatedPositionedDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/basics/09_animated_positioned';
|
||||
|
||||
@override
|
||||
|
||||
@@ -23,6 +23,7 @@ Widget generateContainer(int keyCount) => Container(
|
||||
);
|
||||
|
||||
class AnimatedSwitcherDemo extends StatefulWidget {
|
||||
const AnimatedSwitcherDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/basics/10_animated_switcher';
|
||||
|
||||
@override
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/physics.dart';
|
||||
|
||||
class CardSwipeDemo extends StatefulWidget {
|
||||
const CardSwipeDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/misc/card_swipe';
|
||||
|
||||
@override
|
||||
@@ -78,7 +79,7 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
|
||||
class Card extends StatelessWidget {
|
||||
final String imageAssetName;
|
||||
|
||||
const Card(this.imageAssetName);
|
||||
const Card({required this.imageAssetName, Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -101,10 +102,9 @@ class SwipeableCard extends StatefulWidget {
|
||||
final String imageAssetName;
|
||||
final VoidCallback onSwiped;
|
||||
|
||||
const SwipeableCard({
|
||||
required this.onSwiped,
|
||||
required this.imageAssetName,
|
||||
});
|
||||
const SwipeableCard(
|
||||
{required this.onSwiped, required this.imageAssetName, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_SwipeableCardState createState() => _SwipeableCardState();
|
||||
@@ -135,7 +135,7 @@ class _SwipeableCardState extends State<SwipeableCard>
|
||||
onHorizontalDragStart: _dragStart,
|
||||
onHorizontalDragUpdate: _dragUpdate,
|
||||
onHorizontalDragEnd: _dragEnd,
|
||||
child: Card(widget.imageAssetName),
|
||||
child: Card(imageAssetName: widget.imageAssetName),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class CarouselDemo extends StatelessWidget {
|
||||
CarouselDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/misc/carousel';
|
||||
|
||||
static const List<String> fileNames = [
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CurvedAnimationDemo extends StatefulWidget {
|
||||
const CurvedAnimationDemo({Key? key}) : super(key: key);
|
||||
static const String routeName = '/misc/curved_animation';
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExpandCardDemo extends StatelessWidget {
|
||||
const ExpandCardDemo({Key? key}) : super(key: key);
|
||||
static const String routeName = '/misc/expand_card';
|
||||
|
||||
@override
|
||||
@@ -13,7 +14,7 @@ class ExpandCardDemo extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: const Text('Expandable Card'),
|
||||
),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: ExpandCard(),
|
||||
),
|
||||
);
|
||||
@@ -21,6 +22,7 @@ class ExpandCardDemo extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ExpandCard extends StatefulWidget {
|
||||
const ExpandCard({Key? key}) : super(key: key);
|
||||
@override
|
||||
_ExpandCardState createState() => _ExpandCardState();
|
||||
}
|
||||
|
||||
@@ -5,18 +5,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FocusImageDemo extends StatelessWidget {
|
||||
const FocusImageDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/misc/focus_image';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Focus Image')),
|
||||
body: Grid(),
|
||||
body: const Grid(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Grid extends StatelessWidget {
|
||||
const Grid({Key? key}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -26,8 +28,12 @@ class Grid extends StatelessWidget {
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
itemBuilder: (context, index) {
|
||||
return (index >= 20)
|
||||
? const SmallCard('assets/eat_cape_town_sm.jpg')
|
||||
: const SmallCard('assets/eat_new_orleans_sm.jpg');
|
||||
? const SmallCard(
|
||||
imageAssetName: 'assets/eat_cape_town_sm.jpg',
|
||||
)
|
||||
: const SmallCard(
|
||||
imageAssetName: 'assets/eat_new_orleans_sm.jpg',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -66,10 +72,9 @@ Tween<RelativeRect> _createTween(BuildContext context) {
|
||||
}
|
||||
|
||||
class SmallCard extends StatelessWidget {
|
||||
const SmallCard({required this.imageAssetName, Key? key}) : super(key: key);
|
||||
final String imageAssetName;
|
||||
|
||||
const SmallCard(this.imageAssetName);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HeroAnimationDemo extends StatelessWidget {
|
||||
const HeroAnimationDemo({Key? key}) : super(key: key);
|
||||
static const String routeName = '/misc/hero_animation';
|
||||
|
||||
@override
|
||||
@@ -21,14 +22,16 @@ class HeroAnimationDemo extends StatelessWidget {
|
||||
color: Colors.grey.shade300,
|
||||
),
|
||||
),
|
||||
onTap: () => Navigator.of(context)
|
||||
.push<void>(MaterialPageRoute(builder: (context) => HeroPage())),
|
||||
onTap: () => Navigator.of(context).push<void>(
|
||||
MaterialPageRoute(builder: (context) => const HeroPage())),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HeroPage extends StatelessWidget {
|
||||
const HeroPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/physics.dart';
|
||||
|
||||
class PhysicsCardDragDemo extends StatelessWidget {
|
||||
const PhysicsCardDragDemo({Key? key}) : super(key: key);
|
||||
static const String routeName = '/misc/physics_card';
|
||||
|
||||
@override
|
||||
@@ -26,8 +27,8 @@ class PhysicsCardDragDemo extends StatelessWidget {
|
||||
/// A draggable card that moves back to [Alignment.center] when it's
|
||||
/// released.
|
||||
class DraggableCard extends StatefulWidget {
|
||||
const DraggableCard({required this.child, Key? key}) : super(key: key);
|
||||
final Widget child;
|
||||
const DraggableCard({required this.child});
|
||||
|
||||
@override
|
||||
_DraggableCardState createState() => _DraggableCardState();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RepeatingAnimationDemo extends StatefulWidget {
|
||||
const RepeatingAnimationDemo({Key? key}) : super(key: key);
|
||||
static String routeName = '/misc/repeating_animation';
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user