How to play different animations when a button is tapped depending on the current state?

Advertisements I have a widget that is using a GestureDetector and AnimatedBuilder to play an animation when the button is tapped. I can play a single animation without issue. What I want to do is be able to play three different animations on the button (different colors, different duration) depending on the state. Ex; If… Read More How to play different animations when a button is tapped depending on the current state?

How to animate a drawPaint using a custom painter?

Advertisements I want to achieve this: This is my code: import ‘package:flutter/material.dart’; import ‘dart:math’ as math; class CustomTimePainter extends CustomPainter { CustomTimePainter({ required this.animation, required this.backgroundColor, required this.color, }) : super(repaint: animation); final Animation<double> animation; final Color backgroundColor, color; @override void paint(Canvas canvas, Size size) { var paint = Paint() ..color = const Color.fromARGB(255, 204,… Read More How to animate a drawPaint using a custom painter?

How to make animation value always run from 0 to 1

Advertisements I’m trying to create an animation tween from 0 to 1: final Tween<double> _tween = Tween(begin: 0, end: 1); late AnimationController _controller; late Animation<double> _animation; And for some reason, sometimes I need to call _controller.reverse() or _controller.forward(), and my animation.value runs from 0 to 1 then from 1 to 0. How do I always… Read More How to make animation value always run from 0 to 1

How to animate background color on ElevatedButton?

Advertisements I would like to create a fade between two background colors when my ElevatedButton change his state to disable, how can I do that ? final _buttonStyle = ElevatedButton.styleFrom( backgroundColor: Colors.white, disabledBackgroundColor: Colors.white.withOpacity(0.5), animationDuration: const Duration(milliseconds: 0), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), ); I see there is an animationDuration property, however it seems to only create… Read More How to animate background color on ElevatedButton?

How can i show image in Flutter?

Advertisements I build a folder assets and added there my logo.png. But it shows unable to load asset: assets/logo.png . How can I fix this? Below you can find my code. import ‘package:flutter/material.dart’; import ‘package:color/color.dart’; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends… Read More How can i show image in Flutter?