Feathers custom renderer and themes

Hello, I just wondered if there are a right way to solve this situation. I am working on an app which have light and dark modes. I am implementing it using themes. However the app has a list view with a custom renderer which has a bitmap that changes in both modes, and as far as I know there are no way to know inside the update function which is the active theme. I found a walkaround, I defined a variant for a label in where I set the text with the active mode, and in the update I create a Label and set the variant so checking the text I know in which mode I am. It works however I would like to make it in a more elegant way

Generally, you want to move things that might change based on light-mode/dark-mode selection into the theme. So, for your custom item renderer, you’d have a public property to pass in whichever bitmap that the current mode requires. Then, update() just sees a single bitmap and doesn’t need to choose. The theme will automatically pass in a different bitmap when the mode changes. This should invalidate your item renderer, which calls the update() function again, which can replace the old bitmap with the new one.


That being said, it is possible to detect light-mode/dark-mode from anywhere. The current theme is accessible with Theme.getTheme().

It returns an ITheme, but you can cast it to the appropriate type.

I wouldn’t recommend this approach in your update() function, but it is technically possible.