'flutter OpenContainer problems

Flexible(

          fit: FlexFit.tight, 
          child: OpenContainer(
            closedShape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
            transitionDuration: const Duration(milliseconds: 1000),
            openBuilder: (context, _)  {
              return MealDetailScreen(
                meal: meal,
              );
            },
            closedBuilder: (context, openContainer) {
              return GestureDetector(
                onTap: openContainer,
                child: ClipRRect(
                  borderRadius: BorderRadius.all(Radius.circular(20)),
                  child: Image.asset(
                    meal.imagePath,
                    width: 150,
                    fit: BoxFit.fill,
                  ),
                ),
              );
            },
          ),
        ),

The method 'OpenContainer' isn't defined for the type '_MealCard'. (Documentation) Try correcting the name to the name of an existing method, or defining a method named 'OpenContainer'.

When i try use OpenContainer i am encountering this error. I dont have animations.dart in my flutter version.do i need this dart ? Or is there another source of the problem? What should I do to write the code in the correct format? Thanks to everyone who has helped/tryed to help so far!



Solution 1:[1]

Yes, OpenContainer is part of the animations package and if you want to use it, you must install it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Den loob