'How to remove an animation in Flutter?

I would like to remove an animation and just print the result but I don't know how to remove the animation from this result Here is where the result is:

onPressed: () => Navigator.of(context).push(MaterialPageRoute(
       builder: (context) => NextPage(
           result: (something + other_thing)

And this is how I am printing it:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ValueListenableBuilder<String>(
              valueListenable: _animation,
              builder: (context, value, child) {
                return Text(
                  'The result is $value',   //It has to print the result here, but without any animations
                  style: Theme.of(context).textTheme.headline5,
                  textAlign: TextAlign.center,
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}

I was wondering if I need to remove this ValueListenableBuilder, but I don't know how to access the result from the code above.



Solution 1:[1]

Unless you need to use ValueListenableBuilder, you can use Navigator.push to help you move data between different screens without animations. If you dont know how Navigator works, here is a simple video that explains how it works. https://www.youtube.com/watch?v=NT3XakU4Dcw

Solution 2:[2]

under the hood, navigator execute animation for each action. so just set duration to 0 to remove animation

Navigator.pushReplacement(
  context, 
  PageRouteBuilder(
    pageBuilder: (_, _, _) => MyPage(),
    transitionDuration: const Duration(seconds: 0), // here disabling animation
));

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
Solution 2