ExtendContentList.dart 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'package:flutter/widgets.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import '../models/entities/CardInfo.dart';
  4. class ExtendContentList extends StatelessWidget {
  5. final List<ContentImageList> item;
  6. const ExtendContentList({Key? key, required this.item}) : super(key: key);
  7. Widget? _image(String? content) {
  8. if (null == content || content.isEmpty) return null;
  9. return Image.network(content, fit: BoxFit.cover);
  10. }
  11. Widget? _text(String? content) {
  12. if (null == content || content.isEmpty) return null;
  13. return Text(content);
  14. }
  15. @override
  16. Widget build(BuildContext context) {
  17. return Column(
  18. children: item.map((item) {
  19. if (item.contentType != 'image') {
  20. return Container(
  21. padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
  22. width: 344.w,
  23. child: _text(item.content));
  24. } else {
  25. return Container(
  26. padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
  27. child: _image(item.content),
  28. );
  29. }
  30. }).toList(),
  31. );
  32. }
  33. }