mirror of https://github.com/flutter/samples.git
61 lines
1.6 KiB
61 lines
1.6 KiB
// 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 {
|
|
late final AnimationController _controller;
|
|
late final 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: const 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();
|
|
}
|
|
}
|