diff --git a/README.md b/README.md index 546ecaa..78411e6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The best swiper for flutter , with multiple layouts, infinite loop. Compatible w We are using this project [flutter_page_indicator](https://github.com/best-flutter/flutter_page_indicator) now . -# :sparkles::sparkles: New Features:PageTransformer +# :sparkles::sparkles: flutter_swiper: ^1.1.6 Features:PageTransformer Finally, we have `PageTransformer` like android, just set a `transformer` to `Swiper`, it returns a widget that has been transformed. For now, only support for layout `DEFAULT`. @@ -122,17 +122,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; -void main() => runApp(new MyApp()); +void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Flutter Demo', - theme: new ThemeData( + theme: ThemeData( primarySwatch: Colors.blue, ), - home: new MyHomePage(title: 'Flutter Demo Home Page'), + home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } @@ -143,24 +143,24 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( - title: new Text(widget.title), + return Scaffold( + appBar: AppBar( + title: Text(widget.title), ), - body: new Swiper( + body: Swiper( itemBuilder: (BuildContext context,int index){ - return new Image.network("http://via.placeholder.com/350x150",fit: BoxFit.fill,); + return Image.network("http://via.placeholder.com/350x150",fit: BoxFit.fill,); }, itemCount: 3, - pagination: new SwiperPagination(), - control: new SwiperControl(), + pagination: SwiperPagination(), + control: SwiperControl(), ), ); } @@ -184,13 +184,13 @@ class _MyHomePageState extends State { | onIndexChanged | void onIndexChanged(int index) | Called with the new index when the user swiped or autoplay | | onTap | void onTap(int index) | Called when user tap ui. | | duration | 300.0 | The milliscends of every transaction animation costs | -| pagination | null | set `new SwiperPagination()` to show default pagination -| control | null | set `new SwiperControl()` to show default control buttons +| pagination | null | set `SwiperPagination()` to show default pagination +| control | null | set `SwiperControl()` to show default control buttons #### Pagination -The pagination extends from `SwiperPlugin`,the `SwiperPlugin` provides extra ui for `Swiper`.Set `new SwiperPagination()` to show default pagination. +The pagination extends from `SwiperPlugin`,the `SwiperPlugin` provides extra ui for `Swiper`.Set `SwiperPagination()` to show default pagination. | Parameter | Default | Description | @@ -202,11 +202,11 @@ The pagination extends from `SwiperPlugin`,the `SwiperPlugin` provides extra ui If you'd like to customize your own pagination, you can do like this: ``` -new Swiper( +Swiper( ..., - pagination:new SwiperCustomPagination( + pagination: SwiperCustomPagination( builder:(BuildContext context, SwiperPluginConfig config){ - return new YourOwnPaginatipon(); + return YourOwnPaginatipon(); } ) ); @@ -217,7 +217,7 @@ new Swiper( #### Control buttons -The control also extends from `SwiperPlugin`,set `new SwiperControl()` to show default control buttons. +The control also extends from `SwiperPlugin`,set `SwiperControl()` to show default control buttons. | Parameter | Default | Description | @@ -231,7 +231,7 @@ The control also extends from `SwiperPlugin`,set `new SwiperControl()` to show d #### Controller -The `Controller` is used to control the `index` of the Swiper, start or stop autoplay.You can create a controller by `new SwiperController()` and save the instance by futher usage. +The `Controller` is used to control the `index` of the Swiper, start or stop autoplay.You can create a controller by `SwiperController()` and save the instance by futher usage. | Method | Description | @@ -255,9 +255,9 @@ The `Controller` is used to control the `index` of the Swiper, start or stop aut ![](https://github.com/jzoom/images/raw/master/layout1.gif) ``` -new Swiper( +Swiper( itemBuilder: (BuildContext context, int index) { - return new Image.network( + return Image.network( "http://via.placeholder.com/288x188", fit: BoxFit.fill, ); @@ -274,9 +274,9 @@ new Swiper( ![](https://github.com/jzoom/images/raw/master/layout2.gif) ``` -new Swiper( +Swiper( itemBuilder: (BuildContext context, int index) { - return new Image.network( + return Image.network( "http://via.placeholder.com/288x188", fit: BoxFit.fill, ); @@ -290,9 +290,9 @@ new Swiper( ![](https://github.com/jzoom/images/raw/master/layout3.gif) ``` -new Swiper( +Swiper( itemBuilder: (BuildContext context, int index) { - return new Image.network( + return Image.network( "http://via.placeholder.com/288x188", fit: BoxFit.fill, ); @@ -310,9 +310,9 @@ new Swiper( Very easy to create you own custom animation: ``` - new Swiper( + Swiper( layout: SwiperLayout.CUSTOM, - customLayoutOption: new CustomLayoutOption( + customLayoutOption: CustomLayoutOption( startIndex: -1, stateCount: 3 ).addRotate([ @@ -320,17 +320,17 @@ Very easy to create you own custom animation: 0.0, 45.0/180 ]).addTranslate([ - new Offset(-370.0, -40.0), - new Offset(0.0, 0.0), - new Offset(370.0, -40.0) + Offset(-370.0, -40.0), + Offset(0.0, 0.0), + Offset(370.0, -40.0) ]), itemWidth: 300.0, itemHeight: 200.0, itemBuilder: (context, index) { - return new Container( + return Container( color: Colors.grey, - child: new Center( - child: new Text("$index"), + child: Center( + child: Text("$index"), ), ); }, @@ -342,7 +342,7 @@ The `CustomLayoutOption` is designed to describe animations. It is very easy to specify every state of items in Swiper. ``` -new CustomLayoutOption( +CustomLayoutOption( startIndex: -1, /// Which index is the first item of array below stateCount: 3 /// array length ).addRotate([ // rotation of every item @@ -350,9 +350,9 @@ new CustomLayoutOption( 0.0, 45.0/180 ]).addTranslate([ /// offset of every item - new Offset(-370.0, -40.0), - new Offset(0.0, 0.0), - new Offset(370.0, -40.0) + Offset(-370.0, -40.0), + Offset(0.0, 0.0), + Offset(370.0, -40.0) ]) ``` @@ -362,38 +362,38 @@ new CustomLayoutOption( ![Example](https://github.com/jzoom/images/raw/master/swiper-example.gif) ``` -new ConstrainedBox( - child: new Swiper( +ConstrainedBox( + child: Swiper( outer:false, itemBuilder: (c, i) { - return new Wrap( + return Wrap( runSpacing: 6.0, children: [0,1,2,3,4,5,6,7,8,9].map((i){ - return new SizedBox( + return SizedBox( width: MediaQuery.of(context).size.width/5, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new SizedBox( - child: new Container( - child: new Image.network("https://fuss10.elemecdn.com/c/db/d20d49e5029281b9b73db1c5ec6f9jpeg.jpeg%3FimageMogr/format/webp/thumbnail/!90x90r/gravity/Center/crop/90x90"), + SizedBox( + child: Container( + child: Image.network("https://fuss10.elemecdn.com/c/db/d20d49e5029281b9b73db1c5ec6f9jpeg.jpeg%3FimageMogr/format/webp/thumbnail/!90x90r/gravity/Center/crop/90x90"), ), height: MediaQuery.of(context).size.width * 0.12, width: MediaQuery.of(context).size.width * 0.12, ), - new Padding(padding: new EdgeInsets.only(top:6.0),child: new Text("$i"),) + Padding(padding: EdgeInsets.only(top:6.0),child: Text("$i"),) ], ), ); }).toList(), ); }, - pagination: new SwiperPagination( - margin: new EdgeInsets.all(5.0) + pagination: SwiperPagination( + margin: EdgeInsets.all(5.0) ), itemCount: 10, ), - constraints:new BoxConstraints.loose(new Size(screenWidth, 170.0)) + constraints: BoxConstraints.loose(Size(screenWidth, 170.0)) ), ```