Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.79 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:carousel_slider/carousel_slider.dart';
  3.  
  4. void main() => runApp(DemoApp());
  5.  
  6. class DemoApp extends StatelessWidget {
  7.   List<String> imgList = [
  8.     "assets/albert.jpeg",
  9.     "assets/albert2.jpeg",
  10.   ];
  11.  
  12.   @override
  13.   Widget build(BuildContext context) {
  14.     return Scaffold(
  15.       appBar: AppBar(
  16.         title: Text("Le Saviez-Vous ?"),
  17.       ),
  18.       body: Container(
  19.         child: Column(
  20.           mainAxisAlignment: MainAxisAlignment.center,
  21.           crossAxisAlignment: CrossAxisAlignment.center,
  22.           children: <Widget>[
  23.             CarouselSlider(
  24.               height: 400.0,
  25.               initialPage: 0,
  26.               enlargeCenterPage: true,
  27.               autoPlay: true,
  28.               reverse: false,
  29.               enableInfiniteScroll: true,
  30.               autoPlayInterval: Duration(seconds: 2),
  31.               autoPlayAnimationDuration: Duration(milliseconds: 2000),
  32.               pauseAutoPlayOnTouch: Duration(seconds: 10),
  33.               scrollDirection: Axis.horizontal,
  34.               items: imgList.map((String imgAsset) {
  35.                 return Builder(
  36.                   builder: (BuildContext context) {
  37.                     return Container(
  38.                       width: MediaQuery.of(context).size.width,
  39.                       margin: EdgeInsets.symmetric(horizontal: 10.0),
  40.                       decoration: BoxDecoration(
  41.                         color: Colors.green,
  42.                       ),
  43.                       child: Image.asset(
  44.                         imgAsset,
  45.                         fit: BoxFit.fill,
  46.                       ),
  47.                     );
  48.                   },
  49.                 );
  50.               }).toList(),
  51.             ),
  52.           ],
  53.         ),
  54.       ),
  55.     );
  56.   }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement