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

add carousel, card_swipe, and focus_image samples (#119)

* add carousel, card_swipe, and focus_image samples

* fix image assets

* fix more asset images

* add repeating animation

* fix import

* add copyright headers

* remove Center widget

* imageAssetName

* use ClipRect, refactor _SwipeableCardState

* use offset.zero

* add comments

* remove reference to coverflow package

* change spread to toList()

* refactor coverflow sample

don't set width and height
use const
data -> images

* return widget directly, fix formatting

* inline transitionsBuilder

* image -> imageAssetName

* _rectTween() => _createTween()

* _expandToPageRoute -> _createRoute

* move non-updating widgets out of AnimatedBuilder

* code review updates to animations demos
This commit is contained in:
John Ryan
2019-07-29 09:11:03 -07:00
committed by GitHub
parent 8e4d8c138b
commit 4966440a29
6 changed files with 480 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
class RepeatingAnimationDemo extends StatefulWidget {
static String routeName = '/misc/repeating_animation';
@override
RepeatingAnimationDemoState createState() => RepeatingAnimationDemoState();
}
class RepeatingAnimationDemoState extends State<RepeatingAnimationDemo>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<BorderRadius> _borderRadius;
@override
void initState() {
super.initState();
_controller =
AnimationController(duration: const Duration(seconds: 2), vsync: this)
..repeat(reverse: true);
_borderRadius = BorderRadiusTween(
begin: BorderRadius.circular(100.0),
end: BorderRadius.circular(0.0),
).animate(_controller);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Repeating Animation')),
body: Center(
child: AnimatedBuilder(
animation: _borderRadius,
builder: (context, child) {
return Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: _borderRadius.value,
),
);
},
),
),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}