Use the app theme's defaults

Issue #22 resolved
Alexey Inkin created an issue

There are following issues when trying to use dark theme with flutter_treeview:

1. The background is white by default. This can be overriden with TreeViewTheme, but standard widgets and many custom widgets never require that.

2. The first fix is to add

theme: TreeViewTheme(
  colorScheme: Theme.of(context).colorScheme,
),

But that changes background to near-black while my widget is on a Scaffold with the default grey background, that is nasty.

3. The background is applied to nodes and not the whole widget, so for indented child nodes I see my grey background showing.

4. Expanders remain black even in with ColorScheme which means even more customization needs to be done.

I think the tree should look decent in any theme by default. Neither widget nor nodes should add background of their own, and all the colors should derive from theme, including expanders that should derive their color from text.

Not interfering with the background also adds an ability to place the tree over gradients and images which might be useful for someone in the future.

Comments (4)

  1. Kevin Armstrong

    Alexey, I agree with all the above. I am looking at the necessary changes now and will hopefully have an update soon.

  2. Kevin Armstrong

    Fixes issue #18 - introduced vertical and horizontal spacing Fixes issue #19 - added parent flag to Node to force parent layout Fixes issue #22 - fixed various styling properties with the TreeNode and TreeViewTheme

    → <<cset 1ec5b6375bb8>>

  3. Alexey Inkin reporter

    Thank you for this update, Kevin. I have upgraded from 0.6.0+1 to 0.8.0+1, and the black background is gone.

    However,

    1. Expanders are still black, while they should use text color.
    2. Nodes without expanders lost their indentation, and nodes with expanders now falsely look as being one level under them.

    For this test I used

    ThemeData(
      colorScheme: ColorScheme.dark()
    );
    

    And nodes only have key, label, and children.

  4. Kevin Armstrong

    Hi Alexey, the expander color should have been fixed. I performed a pull request for this update and I have to see if that affected the expander changes. I should have that fixed right away.

  5. Log in to comment