| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import 'dart:math';
- import 'package:fast/utils/size_fit.dart';
- import 'package:flutter/material.dart';
- class Loading extends StatefulWidget {
- bool showBg = true;
- Loading({Key? key, bool? showBackground}) : super(key: key) {
- if (showBackground != null) {
- showBg = showBackground;
- }
- }
- @override
- State<Loading> createState() => _LoadingState();
- }
- class _LoadingState extends State<Loading> with SingleTickerProviderStateMixin {
- late AnimationController controller;
- late Animation animation;
- @override
- void initState() {
- controller = AnimationController(
- vsync: this, duration: const Duration(milliseconds: 1200));
- animation = Tween(begin: 0.0, end: 2 * pi).animate(controller);
- controller.addListener(() {
- setState(() {});
- });
- controller.repeat();
- super.initState();
- }
- @override
- void dispose() {
- controller.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- SizeFit.initialize(context);
- return SizedBox(
- width: 144.px,
- height: 150.px,
- child: Container(
- alignment: Alignment.center,
- child: Container(
- width: 144.px,
- height: 150.px,
- alignment: Alignment.center,
- child: Transform.rotate(
- angle: animation.value,
- child: Image.asset(
- 'assets/images/loading.png',
- width: 80.px,
- height: 80.px,
- ),
- ),
- decoration: widget.showBg
- ? BoxDecoration(
- color: const Color(0xFF313F52),
- borderRadius: BorderRadius.all(Radius.circular(32.px)),
- boxShadow: [
- BoxShadow(
- color: const Color(0xFF000D1F),
- blurRadius: 24.px,
- offset: Offset(0, 12.px))
- ])
- : const BoxDecoration(color: Colors.transparent),
- ),
- ),
- );
- }
- }
|