mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
Samples maintenance (#435)
This commit is contained in:
@@ -13,6 +13,7 @@ Color generateColor() => Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF));
|
||||
class AnimatedContainerDemo extends StatefulWidget {
|
||||
static String routeName = '/basics/01_animated_container';
|
||||
|
||||
@override
|
||||
_AnimatedContainerDemoState createState() => _AnimatedContainerDemoState();
|
||||
}
|
||||
|
||||
@@ -21,6 +22,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
|
||||
double borderRadius;
|
||||
double margin;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
color = Colors.deepPurple;
|
||||
@@ -36,6 +38,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This widget is built using an AnimatedContainer, one of the easiest to use
|
||||
// animated Widgets. Whenever the AnimatedContainer's properties, such as decoration,
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
class PageRouteBuilderDemo extends StatelessWidget {
|
||||
static const String routeName = '/basics/page_route_builder';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
@@ -38,6 +39,7 @@ Route _createRoute() {
|
||||
}
|
||||
|
||||
class _Page2 extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
class TweenDemo extends StatefulWidget {
|
||||
static const String routeName = '/basics/tweens';
|
||||
|
||||
@override
|
||||
_TweenDemoState createState() => _TweenDemoState();
|
||||
}
|
||||
|
||||
@@ -17,6 +18,7 @@ class _TweenDemoState extends State<TweenDemo>
|
||||
AnimationController controller;
|
||||
Animation<double> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -28,11 +30,13 @@ class _TweenDemoState extends State<TweenDemo>
|
||||
animation = Tween(begin: 0.0, end: accountBalance).animate(controller);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
class AnimatedBuilderDemo extends StatefulWidget {
|
||||
static const String routeName = '/basics/animated_builder';
|
||||
|
||||
@override
|
||||
_AnimatedBuilderDemoState createState() => _AnimatedBuilderDemoState();
|
||||
}
|
||||
|
||||
@@ -18,6 +19,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
|
||||
AnimationController controller;
|
||||
Animation<Color> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -26,11 +28,13 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
|
||||
ColorTween(begin: beginColor, end: endColor).animate(controller);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
|
||||
@@ -8,6 +8,7 @@ class TypewriterTween extends Tween<String> {
|
||||
TypewriterTween({String begin = '', String end})
|
||||
: super(begin: begin, end: end);
|
||||
|
||||
@override
|
||||
String lerp(double t) {
|
||||
var cutoff = (end.length * t).round();
|
||||
return end.substring(0, cutoff);
|
||||
@@ -17,6 +18,7 @@ class TypewriterTween extends Tween<String> {
|
||||
class CustomTweenDemo extends StatefulWidget {
|
||||
static const String routeName = '/basics/custom_tweens';
|
||||
|
||||
@override
|
||||
_CustomTweenDemoState createState() => _CustomTweenDemoState();
|
||||
}
|
||||
|
||||
@@ -27,6 +29,7 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
|
||||
AnimationController controller;
|
||||
Animation<String> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -34,11 +37,13 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
|
||||
animation = TypewriterTween(end: message).animate(controller);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
||||
@@ -27,6 +27,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
Colors.purple,
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -49,6 +50,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
animation = TweenSequence<Color>(sequenceItems).animate(controller);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
|
||||
Reference in New Issue
Block a user