Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working properly on iOS #12

Open
kisharora opened this issue Sep 27, 2024 · 0 comments
Open

Not working properly on iOS #12

kisharora opened this issue Sep 27, 2024 · 0 comments

Comments

@kisharora
Copy link

kisharora commented Sep 27, 2024

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-09-27.at.21.18.28.mp4

It leaves blank space under the cards it does not work like it works on android and when you try to scroll, it dissapears.

import 'package:flutter/material.dart';
import 'package:flutter_bounceable/flutter_bounceable.dart';
import 'package:flutter_custom_carousel/flutter_custom_carousel.dart';
import 'package:flutter_animate/flutter_animate.dart';


class MyReservations extends StatefulWidget {
  const MyReservations({super.key});

  @override
  State<MyReservations> createState() => _MyReservationsState();
}

class _MyReservationsState extends State<MyReservations> {
  // int? _selectedIndex;
  final _scrollController = CustomCarouselScrollController();
  List<Widget> items = List.generate(20, (i) => Card(i));

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: DefaultAppBar(size: size, title: 'My Reservations'),
      body: Container(
        color: Colors.orange,
        width: size.width,
        height: size.height,
        child: _buildCarousel(),
      ),
    );
  }

  Widget _buildCarousel() {
    return CustomCarousel(
      itemCountBefore: 4,
      itemCountAfter: 4,
      tapToSelect: true,
      loop: true,
      scrollSpeed: 5,
      controller: _scrollController,
      onSettledItemChanged: (value) => setState(() {
        // _selectedIndex = value;
      }),
      effectsBuilder: CustomCarousel.effectsBuilderFromAnimate(
        effects: EffectList()
            .flipV(begin: -0.25, end: 0.8, perspective: 1)
            .slideY(
              end: 0.5,
            )
            .scaleXY(begin: 0.5, curve: Curves.fastEaseInToSlowEaseOut)
            .align(
              begin: const Alignment(0, -1.5),
              end: const Alignment(0, 5),
              curve: Curves.easeIn,
            ),
      ),
      children: items,
    );
  }
}

class Card extends StatelessWidget {
  const Card(this.index, {super.key});
  final int index;

  @override
  Widget build(BuildContext context) {
    final color1 = Color((0xFF000000 + index * 0x100000).toInt());
    final color2 = Color((0xFFFFFFFF - index * 0x200000).toInt());

    return Bounceable(
      onTap: () {
        AppHaptics.heavyImpact();
      },
      child: FractionallySizedBox(
        widthFactor: 0.8,
        child: AspectRatio(
          aspectRatio: 0.9,
          child: Container(
            decoration: BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
                colors: [color1, color2],
              ),
              border: const Border(
                top: BorderSide(color: Colors.white38, width: 2),
              ),
              borderRadius: BorderRadius.circular(20),
            ),
          ),
        ),
      ),
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant