SlimyCard – Animated Flutter Package

Oct 4, 2021 | Programming

Welcome to the world of brilliant animations in Flutter! The SlimyCard package provides an enchanting slime-like animation that separates a card into two halves: one floating at the top and the other at the bottom. This opens up a realm of customization where you can put any widget you desire into these cards.

Banner Image

How to Install the SlimyCard Package

  • 1. Depend on it
    Add the following to your Flutter app’s pubspec.yaml file:
    dependencies:
      slimy_card: ^1.0.4
  • 2. Install it
    Install packages from the command line using:
    $ flutter pub get
    Alternatively, check your editor’s documentation for its support of flutter pub get.

How to Use the SlimyCard Package

  • 1. Import it
    In your Dart code, import the package:
    import 'package:slimy_card/slimy_card.dart';
  • 2. Use It
    Create a ListView and include the SlimyCard:
    ListView(
      children: [
        SlimyCard(),
      ],
    );
  • 3. Customize It
    Tailor the SlimyCard to your needs using parameters:
    ListView(
      children: [
        SlimyCard(
          color: Colors.red,
          width: 200,
          topCardHeight: 400,
          bottomCardHeight: 200,
          borderRadius: 15,
          topCardWidget: myWidget01(),
          bottomCardWidget: myWidget02(),
          slimeEnabled: true,
        ),
      ],
    );

    myWidget01 and myWidget02 are your custom widgets displayed on the Top and Bottom Cards respectively.

Visual Demonstration

Check out these animated examples of SlimyCard in action:

Real-Time Status Updates

You can monitor the status of SlimyCard in real-time by wrapping it in a StreamBuilder like this:

StreamBuilder(
  initialData: false,
  stream: slimyCard.stream, // Stream of SlimyCard
  builder: ((BuildContext context, AsyncSnapshot snapshot) {
    return ListView(
      children: [
        SlimyCard(
          color: Colors.red,
          width: 200,
          topCardHeight: 400,
          bottomCardHeight: 200,
          borderRadius: 15,
          topCardWidget: myWidget01(),
          bottomCardWidget: myWidget02(),
          slimeEnabled: true,
        ),
      ],
    );
  }),
);

The snapshot.data contains the **real-time** status of the SlimyCard.

State Management with SlimyCard

Changing the state of the SlimyCard is a breeze. Below is an example of how to implement it:

SlimyCard(
  topCardWidget: topCardWidget(
    (snapshot.data)
      ? 'assets/images/rock_aggressive.jpg'
      : 'assets/images/rock_calm.jpg'
  ),
);

Here, snapshot.data determines the state of the SlimyCard and updates the UI accordingly based on its value.

Troubleshooting

If you encounter issues while implementing the SlimyCard package:

  • Ensure your Dart SDK and Flutter are properly installed and updated.
  • Check for any typos in your pubspec.yaml file.
  • Confirm that your custom widgets return the correct widget type.
  • If the animation doesn’t work, check if slimeEnabled: true is set in your SlimyCard.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Final Thoughts

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

About the Creator

Hi! My name is Akash Divya. I am a veteran Designer/Animator with over 10 years of experience. Tired of hearing excuses from developers on design implementations, I decided to embrace Flutter and bring my designs to life!

Explore More!

You may also find these repositories intriguing:

Connect with Me

Now go out there and do what you love!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox