Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show widget when a node (without children) is expanded #97

Open
Uche01 opened this issue May 27, 2024 · 1 comment
Open

Show widget when a node (without children) is expanded #97

Uche01 opened this issue May 27, 2024 · 1 comment

Comments

@Uche01
Copy link

Uche01 commented May 27, 2024

I think it'd be nice to show an optional widget on node expansion when node's children is empty.

Use case: I need to show a button to add child for the root node when the root node is expanded. I tried a hack of replacing the root node with a custom expandable widget, but this came at the expense of not been able to access the root node's properties.

@SeriousMonk
Copy link

SeriousMonk commented Nov 3, 2024

You could just build your expansion tiles like this:

AnimatedSize(
	duration: _collapseAnimationDuration, //e.g. const Duration(milliseconds: 250) this should be the same duration as SliverAnimatedTree.duration
	alignment: Alignment.topCenter,
	child: Column(
	  children: [
		ListTile(
			onTap: (){
			  _treeController.toggleExpansion(entry.node);
			},
			title: Text('This is an expansion tile', style: Theme.of(context).textTheme.bodyMedium, maxLines: 3),
		),
		if(entry.isExpanded && entry.node.children.isEmpty) Text('No items')
	  ],
	)
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants