Refactored so endpoint details are managed in-controller #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋 Hello, I was playing around with the codebase, using this wonderful little app to learn some dart/flutter.
The big if/else blocks, and different arrays, caught my eye when browsing since they looked like something that might be tricky to manage over time, with references as strings in multiple places.
As a little task to learn dart, I thought I'd have a go at implementing an alternative option to managing the endpoints/name of the controllers, so that details only have to be managed in a singular place in a somewhat abstract way.
This PR changes things up so that the controllers themselves manage their name and provided methods.
There's then an
Endpoints
class that manages things at a high level, with a list of controllers.With this setup, additional endpoints can be added all within the controller. No changes to others files are needed.
If there's a new set of endpoints (with a new controller), it just needs to be added to the array
Endpoints
class.Seems to work from my quick bit of testing in an Android emulator. Have tried to keep everything else (including the endpoint/category order) the same as before. Thought I'd create a PR after doing this in-case you'd like this kind of setup.
Please don't feel any pressure to merge this PR though if you're not fond of this approach, this kind of thing can be a matter of preferences, and this is your project. I'm just happy to have learnt some dart via this process.
Also, I have no clue on dart/flutter conventions, so I may not have followed them. If I've done anything you don't understand, feel free to ask.