Fix: image carousel on web
This commit is contained in:
@@ -163,6 +163,12 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double _getAspectRatio() {
|
||||||
|
double width = MediaQuery.sizeOf(context).width;
|
||||||
|
double height = MediaQuery.sizeOf(context).height;
|
||||||
|
return max(width, height) / min(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -191,7 +197,7 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
child: Image.network(
|
child: Image.network(
|
||||||
item!.images[realIdx].url,
|
item!.images[realIdx].url,
|
||||||
width: min(
|
width: min(
|
||||||
800,
|
550,
|
||||||
MediaQuery.sizeOf(context)
|
MediaQuery.sizeOf(context)
|
||||||
.width)),
|
.width)),
|
||||||
);
|
);
|
||||||
@@ -199,7 +205,10 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
carouselController: _carouselController,
|
carouselController: _carouselController,
|
||||||
options: CarouselOptions(
|
options: CarouselOptions(
|
||||||
enlargeCenterPage: true,
|
enlargeCenterPage: true,
|
||||||
aspectRatio: 1,
|
height: min(
|
||||||
|
MediaQuery.sizeOf(context).height -
|
||||||
|
100,
|
||||||
|
400),
|
||||||
enableInfiniteScroll: false,
|
enableInfiniteScroll: false,
|
||||||
onPageChanged: (index, reason) {
|
onPageChanged: (index, reason) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -239,7 +248,7 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
])
|
])
|
||||||
: Image.network(item!.images[0].url,
|
: Image.network(item!.images[0].url,
|
||||||
width: min(
|
width: min(
|
||||||
800, MediaQuery.sizeOf(context).width)),
|
550, MediaQuery.sizeOf(context).width)),
|
||||||
item!.description != ''
|
item!.description != ''
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsetsDirectional.all(30),
|
padding: const EdgeInsetsDirectional.all(30),
|
||||||
|
|||||||
Reference in New Issue
Block a user