styles.dart 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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({
  8. double? opacity,
  9. double? width,
  10. double? height,
  11. bool? repeat,
  12. }) {
  13. return (context, child, frame, wasSynchronouslyLoaded) {
  14. if (wasSynchronouslyLoaded) {
  15. return child;
  16. }
  17. return AnimatedSwitcher(
  18. duration: const Duration(milliseconds: 0),
  19. child: frame != null
  20. ? child
  21. : Center(
  22. child: Opacity(
  23. opacity: opacity ?? 0.22,
  24. child: Lottie.asset(Assets.anim.animNoPhoto,
  25. width: width ?? 140.w,
  26. height: height ?? 140.w,
  27. repeat: repeat ?? true),
  28. )));
  29. };
  30. }
  31. static ImageFrameBuilder? customFrameBuilder({
  32. double? opacity,
  33. double? width,
  34. double? height,
  35. bool? repeat,
  36. }) {
  37. return (context, child, frame, wasSynchronouslyLoaded) {
  38. if (wasSynchronouslyLoaded) {
  39. return child;
  40. }
  41. return AnimatedSwitcher(
  42. duration: const Duration(milliseconds: 0),
  43. child: frame != null
  44. ? child
  45. : Center(
  46. child: Opacity(
  47. opacity: opacity ?? 0.22,
  48. child: Lottie.asset(Assets.anim.animNoPhoto,
  49. width: width ?? 140.w,
  50. height: height ?? 140.w,
  51. repeat: repeat ?? true))));
  52. };
  53. }
  54. }