Same bloc functions in different screens

Viewed 73

I'm having a serious issue with code duplication because I have created 2 different instances from a Bloc that holds the color change of a button and provided them to 2 screens. I wanted them to act independently, but unfortunately, both buttons work the same. Can anyone give me a clue to achieve this without creating another bloc for the next screen?. I have provided the bloc to the main screen and on the 2nd screen, I have bottom navigation and it has 2 screens.

1 Answers

You can define a class yourBlock with your functions ecc then in your pages you can include that custom block and use it as you want.. so if you need to add, modify or to do anything on your code you have to do only once in your custom class

Related