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
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -191,7 +197,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
child: Image.network(
|
||||
item!.images[realIdx].url,
|
||||
width: min(
|
||||
800,
|
||||
550,
|
||||
MediaQuery.sizeOf(context)
|
||||
.width)),
|
||||
);
|
||||
@@ -199,7 +205,10 @@ class _DetailPageState extends State<DetailPage> {
|
||||
carouselController: _carouselController,
|
||||
options: CarouselOptions(
|
||||
enlargeCenterPage: true,
|
||||
aspectRatio: 1,
|
||||
height: min(
|
||||
MediaQuery.sizeOf(context).height -
|
||||
100,
|
||||
400),
|
||||
enableInfiniteScroll: false,
|
||||
onPageChanged: (index, reason) {
|
||||
setState(() {
|
||||
@@ -239,7 +248,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
])
|
||||
: Image.network(item!.images[0].url,
|
||||
width: min(
|
||||
800, MediaQuery.sizeOf(context).width)),
|
||||
550, MediaQuery.sizeOf(context).width)),
|
||||
item!.description != ''
|
||||
? Padding(
|
||||
padding: const EdgeInsetsDirectional.all(30),
|
||||
|
||||
Reference in New Issue
Block a user