dependencies: flutter_swiper: ^1.1.6
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'dart:ui';
void main()=>runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SwiperPage(),
);
}
}
class SwiperPage extends StatefulWidget {
@override
SwiperPageState createState() {
return SwiperPageState();
}
}
class SwiperPageState extends State<SwiperPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: window.physicalSize.width,
height: window.physicalSize.height,
child: Swiper(
itemBuilder: (context,index)=>Image.network('http://www.ecobentech.com/images/$index.jpg',fit: BoxFit.cover,),
itemCount: 3,
pagination: SwiperPagination(
builder: DotSwiperPaginationBuilder(
color: Colors.orange,
activeColor: Colors.green,
),
),
control:SwiperControl(),
scrollDirection: Axis.vertical,
autoplay: true,
onTap: (index) => print('点击了第$index个'),
)),
);
}
}