omerbyrk/add_to_cart_animation

Error: Unexpected null value. "StatelessWidget with ChangeNotifier"

Closed this issue · 1 comments

Error used controller with ChangeNotifier

Cod:

 void listClick(GlobalKey widgetKey) async {
    try {
    // here ***********
      await runAddToCartAnimation(widgetKey);
    } catch (e) {
      print(e);
    }
   await cartKey.currentState!.runCartAnimation((++cartTotalItems).toString());

}

Error used controller with ChangeNotifier

Cod:

 void listClick(GlobalKey widgetKey) async {
    try {
    // here ***********
      await runAddToCartAnimation(widgetKey);
    } catch (e) {
      print(e);
    }
   await cartKey.currentState!.runCartAnimation((++cartTotalItems).toString());

}

I forgot to associate the key in the widget that has the animation
Container(
key: controller.widgetKey,
[...]
}