import 'package:flutter/material.dart'; /// Description: guide页 /// Time : 05/01/2023 Monday /// Author : liuyuqi.gov@msn.cn class Walkthrough extends StatefulWidget { final title; final content; final imageIcon; final imagecolor; /// 构造函数 /// title: 标题 /// content: 内容 /// imageIcon: 图标 /// imagecolor: 图标颜色 Walkthrough( {this.title, this.content, this.imageIcon, this.imagecolor = Colors.redAccent}); @override WalkthroughState createState() { return WalkthroughState(); } } class WalkthroughState extends State with SingleTickerProviderStateMixin { late Animation animation; late AnimationController animationController; @override void initState() { super.initState(); animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500)); animation = Tween(begin: -250.0, end: 0.0).animate( CurvedAnimation(parent: animationController, curve: Curves.easeInOut)); animation.addListener(() => setState(() {})); animationController.forward(); } @override void dispose() { super.dispose(); animationController.dispose(); } @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(20.0), child: Material( animationDuration: Duration(milliseconds: 500), elevation: 2.0, borderRadius: BorderRadius.all(Radius.circular(5.0)), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Transform( transform: Matrix4.translationValues(animation.value, 0.0, 0.0), child: Text( widget.title, style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black), ), ), Transform( transform: Matrix4.translationValues(animation.value, 0.0, 0.0), child: Text(widget.content, softWrap: true, textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.normal, fontSize: 15.0, color: Colors.black)), ), Icon( widget.imageIcon, size: 100.0, color: widget.imagecolor, ) ], ), ), ); } }