You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
Our flutter code base is growing rapidly and we need to agree on some basic structuring and code styles. I am already following some patterns, but I want to bring this up here so we all get a say on the way forward.
As a principle guideline I think we should generally align with the effective dart rules.
That being said here is my proposal for the flutter project structure. As an abstract structure it should look like the following
Module
A logical collection of cohesive code. e.g. cfd_trading
Models: Any data model relevant to that module. If relevant to multiple modules without a clear parent. We could move it to a common model. e.g. order, service_model, etc.
Services: Contains the state providers or any other business or integration logic. e.g. balance_model, cfd_trading_state, etc.
Screens: Contains the top level screens or major pages. e.g. cfd_trading, cfd_offer, dashboard, seed, etc.
Widgets: Contains small helper UI widgets, which could be reused. However, these widgets should not contain any relevant data, but only format data in a generic way e.g. with the goal to make the code in the screen more readable. (It must not split the data processing into smaller chunks). I guess this will mostly be used by the common module and would contain our current utilities folder.
Additional guidelines
(only a current proposal from what I've seen so far in the code and I think makes sense - please don't take this as carved in stone - lets discuss)
The file name should map the (main) class name. e.g. cfd_order_confirmation.dart-> class CfdOrderConfirmation
If possible the file should only contain one class to prevent endless scrolling.
Any class (and filename) should include the parent folder in its name. e.g. CfdTradingService, OrderModel, SeedScreen, etc.
Keep cohesive code together
Don't make your low level widget opinionated about spacing or data.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Flutter project structure and code style
Our flutter code base is growing rapidly and we need to agree on some basic structuring and code styles. I am already following some patterns, but I want to bring this up here so we all get a say on the way forward.
As a principle guideline I think we should generally align with the effective dart rules.
That being said here is my proposal for the flutter project structure. As an abstract structure it should look like the following
Module
A logical collection of cohesive code. e.g. cfd_trading
Models: Any data model relevant to that module. If relevant to multiple modules without a clear parent. We could move it to a common model. e.g. order, service_model, etc.
Services: Contains the state providers or any other business or integration logic. e.g. balance_model, cfd_trading_state, etc.
Screens: Contains the top level screens or major pages. e.g. cfd_trading, cfd_offer, dashboard, seed, etc.
Widgets: Contains small helper UI widgets, which could be reused. However, these widgets should not contain any relevant data, but only format data in a generic way e.g. with the goal to make the code in the screen more readable. (It must not split the data processing into smaller chunks). I guess this will mostly be used by the common module and would contain our current utilities folder.
Additional guidelines
(only a current proposal from what I've seen so far in the code and I think makes sense - please don't take this as carved in stone - lets discuss)
cfd_order_confirmation.dart
->class CfdOrderConfirmation
Beta Was this translation helpful? Give feedback.
All reactions