0

I have an AnimatedPositioned widget that listens to a variable (called show). When the variable changes to true, it appears from the bottom of the screen to the center. How do I properly do a widget test of this? I'm new in widget testing in Flutter.

This is my widget:

Widget build(BuildContext context) {
    return SizedBox(
      width: MediaQuery.of(context).size.width,
      height: 350,
      child: Stack(
        children: <Widget>[
          Obx(
            () => AnimatedPositioned(
              width: show.value
                  ? MediaQuery.of(context).size.width
                  : MediaQuery.of(context).size.width,
              height:
                  show.value ? MediaQuery.of(context).size.height * 0.3 : 0.0,
              bottom: show.value ? 0.0 : 0.0,
              duration: const Duration(milliseconds: 800),
              curve: Curves.linearToEaseOut,
              child: AnimatedOpacity(
                duration: const Duration(milliseconds: 500),
                opacity: show.value ? 1 : 0.8,
                child: GestureDetector(
                  onTap: () {},
                  child: Container(
                    color: Colors.green,
                    child: const Center(child: Text('Tap me')),
                  ),
                ),
              ),
            ),
          ),
          Obx(() => Text(show.value.toString()))
        ],
      ),
    );
  }
lemon-dev
  • 11
  • 1

0 Answers0