知识 Flutter Flutter-SmoothPageIndicator-Lottie Kahvia 2022-10-27 2022-10-28 SmoothPageIndicator
平滑的页面指示器。我称它为点集。效果与 dots indicator 类似,但样式更多样。
依赖引入
1 smooth_page_indicator: ^1.0.0+2
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 SmoothPageIndicator( controller: _controller, count: 3 , onDotClicked: (index){ _controller.jumpToPage(index); }, effect: SwapEffect( activeDotColor: Colors.deepPurple, dotColor: Colors.deepPurple.shade200 ), )
Lottie
一个可以渲染动态特效的工具。常用于渲染 AE 导出的 json 格式的特效。
可配合LottieFiles 使用。
依赖引入
使用
1 2 Lottie.asset("assets/lotties/wifi-high-speed-internet.json" ) Lottie.network("https://assets5.lottiefiles.com/packages/lf20_mdxpRNhzMQ.json" )
两者结合
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 class IntroductionScreensPage extends StatelessWidget { final PageController _controller=PageController(); IntroductionScreensPage({super .key}); @override Widget build(BuildContext context) { return Stack( alignment: const AlignmentDirectional(0 , 0.75 ), children: [ PageView( controller: _controller, children: const [ IntroductionPage1(), IntroductionPage2(), IntroductionPage3() ], ), SmoothPageIndicator( controller: _controller, count: 3 , onDotClicked: (index){ _controller.jumpToPage(index); }, effect: SwapEffect( activeDotColor: Colors.deepPurple, dotColor: Colors.deepPurple.shade200 ), ) ], ); } } class IntroductionPage1 extends StatelessWidget { const IntroductionPage1({Key? key}) : super (key: key); @override Widget build(BuildContext context) { return Scaffold( body: Container( color: Colors.deepPurple.shade300, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const SizedBox(height: 30 ,), const Text( "It's Achat" , style: TextStyle( fontFamily: "Bebas_Neue" , fontSize: 70 , color: Colors.white ), ), Lottie.asset("assets/lotties/talk-show2.json" ), const SizedBox(height: 70 ,), ], ), ), ); } }
效果图