import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/brand.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class BrandView extends StatefulWidget { final List brandData; BrandView(this.brandData); @override State createState() { return _BrandView(); } } class _BrandView extends State { final SwiperController swiperController = SwiperController(); @override Widget build(BuildContext context) { return Column( children: [ ItemTitle( text: S.of(context).pinpaijieshao, imgPath: "assets/image/icon_brand_introduction.png", ), brands(), ], ); } brands() { return Container( height: 90.h, margin: EdgeInsets.only(bottom: 18.h), child: Swiper( controller: swiperController, viewportFraction: 0.32, scale: 0.7, autoplay: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return Container( margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withAlpha(37), offset: Offset(0, 2), blurRadius: 5, spreadRadius: 0, ), ], borderRadius: BorderRadius.circular(8), ), child: MImage( widget.brandData != null ? widget.brandData[position].image : "", radius: BorderRadius.circular(8), fit: BoxFit.cover, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), ); }, itemCount: (widget.brandData != null && widget.brandData.length > 0) ? widget.brandData.length : 0, ), ); } }