styles.dart 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:flutter/Material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:lottie/lottie.dart';
  4. import '../resource/assets.gen.dart';
  5. class Styles {
  6. Styles._();
  7. static ImageFrameBuilder? animFrameBuilder({double? opacity, double? width,
  8. double? height, bool? repeat,}) {
  9. return (context, child,
  10. frame, wasSynchronouslyLoaded) {
  11. if (wasSynchronouslyLoaded) {
  12. return child;
  13. }
  14. return AnimatedSwitcher(
  15. duration: const Duration(
  16. milliseconds: 0),
  17. child: frame != null
  18. ? child
  19. : Center(
  20. child: Opacity(
  21. opacity: opacity ?? 0.22,
  22. child: Lottie.asset(
  23. Assets
  24. .anim.animNoPhoto,
  25. width: width ?? 140.w,
  26. height: height ?? 140.w,
  27. repeat: repeat ?? true
  28. ),
  29. )));
  30. };
  31. }
  32. static ImageFrameBuilder? customFrameBuilder({double? opacity, double? width,
  33. double? height, bool? repeat,}) {
  34. return (context, child,
  35. frame, wasSynchronouslyLoaded) {
  36. if (wasSynchronouslyLoaded) {
  37. return child;
  38. }
  39. return AnimatedSwitcher(
  40. duration: const Duration(
  41. milliseconds: 0),
  42. child: frame != null
  43. ? child
  44. : Center(
  45. child: Opacity(
  46. opacity: opacity ?? 0.22,
  47. child:const CircularProgressIndicator(color: Colors.white38,),
  48. )));
  49. };
  50. }
  51. }