1234567891011121314151617181920212223242526272829303132333435363738394041 |
-
- import 'package:flutter/widgets.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
-
- import '../models/entities/ExtendContent.dart';
-
- class ExtendContentList extends StatelessWidget {
- final List<ExtendContent> list;
-
- ExtendContentList({ Key? key, required this.list }) : super(key: key);
-
- Widget? _image(String? content) {
- if (null == content || content.isEmpty) return null;
- return Image.network(content, fit: BoxFit.cover);
- }
-
- Widget? _text(String? content) {
- if (null == content || content.isEmpty) return null;
- return Text(content);
- }
-
- @override
- Widget build(BuildContext context) {
-
- List<Widget> _widgets = [];
- for (var i = 0; i < list.length; i += 1) {
- if (i != 0 ) {
- _widgets.add(SizedBox(height: 20.w,));
- }
- var item = list[i];
- _widgets.add(Container(
- child: item.contentType == "image" ? _image(item.content) : _text(item.content),
- ));
- }
-
- return Column(
- children: _widgets,
- );
- }
-
- }
|