mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 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 {
|
|
const RepeatingAnimationDemo({super.key});
|
|
static String routeName = 'misc/repeating_animation';
|
|
|
|
@override
|
|
State<RepeatingAnimationDemo> 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();
|
|
}
|
|
}
|