From aee3f5018e0f480c9ec0180c9b10b630e4bc08d7 Mon Sep 17 00:00:00 2001 From: cho4u4o Date: Tue, 29 Oct 2024 13:04:47 +0900 Subject: [PATCH] design : make carousel responsive --- lib/screens/main/main_screen.dart | 5 +++-- lib/widgets/carousel.dart | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/screens/main/main_screen.dart b/lib/screens/main/main_screen.dart index cceff9c..492b579 100644 --- a/lib/screens/main/main_screen.dart +++ b/lib/screens/main/main_screen.dart @@ -51,6 +51,7 @@ class _MainScreenState extends State { @override Widget build(BuildContext context) { + double screenHeight = MediaQuery.of(context).size.height; return Scaffold( appBar: AppBar( centerTitle: false, @@ -86,8 +87,8 @@ class _MainScreenState extends State { backgroundColor: altWhite, body: CustomScrollView( slivers: [ - const SliverToBoxAdapter( - child: Carousel(), + SliverToBoxAdapter( + child: Carousel(screenHeight: screenHeight), ), SliverToBoxAdapter( child: Padding( diff --git a/lib/widgets/carousel.dart b/lib/widgets/carousel.dart index 1f9f68e..60c21fc 100644 --- a/lib/widgets/carousel.dart +++ b/lib/widgets/carousel.dart @@ -5,7 +5,8 @@ import 'package:saphy/utils/colors.dart'; import 'package:saphy/utils/textstyles.dart'; class Carousel extends StatelessWidget { - const Carousel({super.key}); + double screenHeight; + Carousel({super.key, required this.screenHeight}); @override Widget build(BuildContext context) { @@ -30,7 +31,7 @@ class Carousel extends StatelessWidget { child: CarouselSlider.builder( itemCount: itemList.length, options: CarouselOptions( - height: 575, + height: screenHeight * 0.6, viewportFraction: 1, enlargeCenterPage: false, autoPlay: true,