基础组件库
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

84 satır
2.0 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:shimmer/shimmer.dart';
  3. import 'package:zhiying_comm/util/empty_util.dart';
  4. class HomeBannerSkeleton extends StatelessWidget {
  5. final Map<String, dynamic> model;
  6. const HomeBannerSkeleton(this.model);
  7. @override
  8. Widget build(BuildContext context) {
  9. return Container(
  10. height: 60,
  11. width: double.infinity,
  12. color: Colors.white,
  13. child: _styleWidget(EmptyUtil.isEmpty(model) ? 1 : model.containsKey('mod_name') ? _getCount(model['mod_name']) : 1),
  14. );
  15. }
  16. int _getCount(String modName) {
  17. if (!EmptyUtil.isEmpty(modName)) {
  18. if (modName.endsWith('one')) {
  19. return 1;
  20. }
  21. if (modName.endsWith('two')) {
  22. return 2;
  23. }
  24. if (modName.endsWith('three')) {
  25. return 3;
  26. }
  27. if (modName.endsWith('four')) {
  28. return 4;
  29. }
  30. if (modName.endsWith('five')) {
  31. return 5;
  32. }
  33. }
  34. return 1;
  35. }
  36. Widget _styleWidget(int size) {
  37. List data = [];
  38. for(int i = 0 ; i < size; i++){
  39. data.add(i);
  40. }
  41. return Row(
  42. children: data.map((index){
  43. var margin;
  44. // if(index == 0 && size !=1){
  45. // margin = const EdgeInsets.only(right: 10,);
  46. // }else if(index == size -1 && size != 2 && size != 1){
  47. // margin = const EdgeInsets.only(left: 10);
  48. // }else{
  49. // margin = const EdgeInsets.only(left: 10, right: 10);
  50. // }
  51. margin = const EdgeInsets.only(left: 10, right: 10);
  52. return Flexible(
  53. flex: 1,
  54. child: Shimmer.fromColors(
  55. baseColor: Colors.grey[300],
  56. highlightColor: Colors.grey[100],
  57. child: Container(
  58. height: double.infinity,
  59. width: double.infinity,
  60. margin: margin,
  61. decoration: BoxDecoration(
  62. color: Colors.white,
  63. borderRadius: BorderRadius.circular(7.5),
  64. ),
  65. ),
  66. ),
  67. );
  68. }).toList(),
  69. );
  70. }
  71. }