infinite_carousel 0.0.2 infinite_carousel: ^0.0.2 copied to clipboard
Carousel in flutter. Supports infinite looping and gives control over anchor and velocity.
import 'package:flutter/material.dart';
import 'package:infinite_carousel/infinite_carousel.dart';
import 'screens/complex.dart';
import 'screens/horizontal.dart';
import 'screens/vertical.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Infinite Carousel Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Infinite Carousel Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
InfiniteScrollController controller;
int selectedIndex = 0;
@override
void initState() {
super.initState();
controller = InfiniteScrollController();
}
@override
void dispose() {
super.dispose();
controller?.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Column(
children: [
RaisedButton(
child: Text('Horizontal example'),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Horizontal()));
},
),
RaisedButton(
child: Text('Vertical example'),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Vertical()));
},
),
RaisedButton(
child: Text('Complex example'),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Complex()));
},
),
],
),
);
}
}