Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter rotate animation icon on press

@override
  void initState() {
    super.initState();

    _controller = AnimationController(
      vsync: this,
      duration: Duration(milliseconds: 300),
      upperBound: 0.5,
    );
  }
  
  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }
  
  RotationTransition(
              turns: Tween(begin: 0.0, end: 0.5).animate(_controller),
              child: IconButton(
                icon: Icon(Icons.expand_less),
                onPressed: () {
                  setState(() {
                    if (_expanded) {
                      _controller..reverse(from: 0.5);
                    } else {
                      _controller..forward(from: 0.0);
                    }
                    _expanded = !_expanded;
                  });
                },
              ),
            )
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flutter #rotate #animation #icon #press
ADD COMMENT
Topic
Name
5+4 =