baumths / flutter_tree_view

A Flutter collection of widgets and slivers that helps bringing your hierarchical data to life.
https://baumths.github.io/flutter_tree_view
MIT License
175 stars 63 forks source link

ExpandIcon should have a IconData field to overwrite Icons.expand_more #67

Closed stephane-archer closed 12 months ago

baumths commented 12 months ago

Hey @stephane-archer , thank you for using the package!

The ExpandIcon widget is part of the flutter flamework.

Ref: https://api.flutter.dev/flutter/material/ExpandIcon-class.html

stephane-archer commented 12 months ago

@baumths you are welcome, I didn't know ExpandIcon was part of Flutter. If we can't customize ExpandIcon then I would be glad if we could replace it with another class of your own or that the user defines.

baumths commented 12 months ago

As the flutter framework already provides such a widget, I would recommend you to file an issue there so they add more customization options to the ExpandIcon widget instead.

In the meantime, I've put together an example using the AnimatedRotation widget, which you can copy and tweak to look as desired:

class MyExpandIcon extends StatefulWidget {
  const MyExpandIcon({super.key});

  @override
  State<MyExpandIcon> createState() => MyExpandIconState();
}

class MyExpandIconState extends State<MyExpandIcon> {
  bool isExpanded = false;

  @override
  Widget build(BuildContext context) {
    return IconButton(
      onPressed: () => setState(() => isExpanded = !isExpanded),
      icon: AnimatedRotation(
        turns: isExpanded ? 0.5 : 0,
        duration: kThemeAnimationDuration,
        child: const Icon(Icons.chevron_right),
      ),
    );
  }
}