flutter_tree_view icon indicating copy to clipboard operation
flutter_tree_view copied to clipboard

Would be better if TreeNode<T>

Open lvyandev opened this issue 4 years ago • 4 comments

Very nice lib! It would be better if treeNode has generic type to make it easier to access data's fields without cast.

lvyandev avatar Jun 01 '21 09:06 lvyandev

Hey, thank you for trying the package out!

I have worked with that before but <T> was lost somewhere and I still had to cast it in the example.

Any suggestions on how to approach this without making every class accept generics?

baumths avatar Jun 01 '21 11:06 baumths

Any suggestions on how to approach this without making every class accept generics?

For now I haven't figured out a solution, or It might be suggested to write generics everywhere according to linter:rules - always_specify_types

lvyandev avatar Jun 01 '21 11:06 lvyandev

For now I haven't figured out a solution, or It might be suggested to write generics everywhere according to linter:rules - always_specify_types

It's also written in there that we should use Object if we need that variable to override == and hashcode.

With generics I can't guarantee that the variable won't be dynamic.

Edit: perhaps using <T extends Object> would solve that issue...

baumths avatar Jun 01 '21 12:06 baumths

Sure, I didn't see that. Could give it a try

lvyandev avatar Jun 01 '21 12:06 lvyandev