Flutter动画效果插件cool_animations的使用
Flutter动画效果插件cool_animations的使用
Cool Animations
Cool Animations 是一个简单且色彩丰富的动画库,它由 Flutter 构建。
维护者: Tanmoy Karmakar
规格
这个库允许你轻松地实现带有惊人曲线的动画图标。
它完全用 Dart 编写。
安装
在你的 pubspec.yaml
文件中添加以下依赖项:
dependencies:
cool_animations: ^0.0.3
示例代码
以下是一个简单的使用示例:
import 'package:cool_animations/cool_animations.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Material App',
home: Homepage(),
);
}
}
class Homepage extends StatefulWidget {
const Homepage({Key? key}) : super(key: key);
@override
_HomepageState createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Cool animations'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BounceWidget(
onTap: (val) {
// 忽略: 避免打印
print(val);
},
),
RotateWidget(
onTap: (val) {
// 忽略: 避免打印
print(val);
},
inactiveIcon: Icons.hourglass_empty_rounded,
activeIcon: Icons.hourglass_full_rounded,
activeColor: Colors.blue,
),
],
),
),
);
}
}
简单使用
要集成简单的底部导航栏,只需使用以下代码:
BounceWidget(
onTap: (val) {
// 忽略: 避免打印
print(val);
},
),
更多关于Flutter动画效果插件cool_animations的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复