Flutter —— 轮播图

turboksFlutter76

1.pubspec.yaml

  flutter_swiper: ^1.1.6 # 轮播图


2.自定义一个类

import 'package:flutter/material.dart';

import 'package:flutter_swiper/flutter_swiper.dart';

import 'package:ks/pages/home/homeModel.dart';


class CommonSwiper extends StatelessWidget {

  final List<ImageAdList> images;


  const CommonSwiper({Key? key, required this.images}) : super(key: key);


  @override

  Widget build(BuildContext context) {

    var height = MediaQuery.of(context).size.width / 750.0 * 300;

    return Container(

      height: height,

      child: Swiper(

        itemCount: images.length,

        itemBuilder: (context, index) {

          return Image.network(

            "http://pls.asj.com/" + images[index].defaultImage.toString(),

            fit: BoxFit.fill,

          );

        },

        pagination: SwiperPagination(),

        autoplay: true,

      ),

    );

  }

}


3.使用

            //轮播

            CommonSwiper(images: model.data.imageAdList),



相关文章

Flutter —— 路由

Flutter —— 路由

1. pubspec.yamlfluro: ^1.5.1 #路由2. 路由管理中心    // ignore: import_of_legacy_library...

Flutter —— 使用RGB颜色

Flutter —— 使用RGB颜色

import 'dart:ui';extension HexColor on Color {  /// String is in the format "aabbc...

Flutter —— TabBarView每次进入都刷新?

Flutter —— TabBarView每次进入都刷新?

import 'package:flutter/material.dart';class PageOne extends StatefulWidget {const PageOne({...

Flutter —— 网络请求

Flutter —— 网络请求

1.pubspec.yamldio: ^3.0.9 #网络请求2.使用    var url = "urlurlurlurlurl";   ...

Flutter —— 原生交互

Flutter —— 原生交互

一:传递数据flutter:var methodChannel = const MethodChannel("ksapp");onPressed: () {// sendToAnd...

Flutter —— 左右切换视图

Flutter —— 左右切换视图

import 'package:flutter/material.dart';import 'package:ks/pageone.dart';import '...