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

add animations basics 1-6 (#120)

* add basics

* web: update dependencies

* TransferableTypeData added (#116)

* Updating index with new samples (#121)

* use arrow functions

* remove newline

* use verbs: random*() -> generate*()

* remove <Widget>[] type annotation on lists

* use raised button

* _route() => _createRoute()

* add parameter names to pageBuilder

* use the text theme's display1 for large text

* dispose animation controllers before calling super()

* remove local var

* use raised buttons instead of material buttons

* web: updated dependencies

* Added new test scripts (#122)

* 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:23:04 -07:00
committed by GitHub
parent 4966440a29
commit 734b961c57
8 changed files with 350 additions and 3 deletions

View File

@@ -0,0 +1,69 @@
import 'dart:math';
import 'package:flutter/material.dart';
const _duration = Duration(milliseconds: 400);
double generateBorderRadius() => Random().nextDouble() * 64;
double generateMargin() => Random().nextDouble() * 64;
Color generateColor() => Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF));
class AnimatedContainerDemo extends StatefulWidget {
static String routeName = '/basics/01_animated_container';
_AnimatedContainerDemoState createState() => _AnimatedContainerDemoState();
}
class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
Color color;
double borderRadius;
double margin;
void initState() {
super.initState();
color = Colors.deepPurple;
borderRadius = generateBorderRadius();
margin = generateMargin();
}
void change() {
setState(() {
color = generateColor();
borderRadius = generateBorderRadius();
margin = generateMargin();
});
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: 128,
height: 128,
child: AnimatedContainer(
margin: EdgeInsets.all(margin),
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(borderRadius),
),
duration: _duration,
),
),
),
RaisedButton(
child: Text(
'change',
),
onPressed: () => change(),
),
],
),
),
);
}
}