import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/article.dart'; import 'package:huixiang/view_widget/hot_item.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class HotArticle extends StatefulWidget { final List
articles; HotArticle(this.articles); @override State createState() { return _HotArticle(); } } class _HotArticle extends State { @override Widget build(BuildContext context) { return Column( children: [ ItemTitle( text: S.of(context).huixiangtoutiao, imgPath: "assets/image/icon_today_video.png", moreText: S.of(context).chakangengduo, onTap: () { Navigator.of(context) .pushNamed('/router/hot_article_page'); }, ), hotList(), ], ); } Widget hotList() { return Container( child: ListView.builder( shrinkWrap: true, itemCount: widget.articles != null ? ((widget.articles.length > 3) ? 3 : widget.articles.length) : 0, physics: NeverScrollableScrollPhysics(), scrollDirection: Axis.vertical, padding: EdgeInsets.symmetric(vertical: 12.h), itemBuilder: (context, position) { return AspectRatio( aspectRatio: position == 0 ? 1.38 : 3.56, child: Container( height: position == 0 ? 247.h : 96.h, margin: EdgeInsets.symmetric(vertical: 6.h, horizontal: 16.w), child: HotArticleItem( article: widget.articles[position], isHot: position == 0), ), ); }, ), ); } }