Created
May 8, 2020 16:01
-
-
Save becek2n/0afb2f4f5eb85e1e2448c41f5e80917f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int _current = 0; | |
Widget build(BuildContext context) { | |
return Column( | |
children: <Widget>[ | |
CarouselSlider( | |
options: CarouselOptions( | |
autoPlay: true, | |
height: 250, | |
viewportFraction: 1.0, | |
onPageChanged: (index, reason) { | |
setState(() { | |
_current = index; | |
}); | |
}, | |
), | |
items: imgNews.map( | |
(url) { | |
return Container( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
ClipRRect( | |
child: Image.asset( | |
url, | |
fit: BoxFit.fill, | |
height: 250, | |
), | |
), | |
], | |
) | |
); | |
}, | |
).toList(), | |
), | |
Padding( | |
padding: EdgeInsets.only(top:10), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: map<Widget>(imgNews, (index, url) { | |
return Container( | |
width: 6.0, | |
height: 8.0, | |
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 5.0), | |
decoration: BoxDecoration( | |
shape: BoxShape.circle, | |
color: _current == index ? Colors.red : Colors.blueGrey, | |
), | |
); | |
}), | |
), | |
), | |
] | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment