Where to place custom helper classes in Flutter BLoC architecture
612
Indeed there is no standard best practice to put it. In my own opinion, create a separate folder called utils
or util
or helper
or helpers
and put it there. This is reasonable, since helpers are themselves not a model (so may not be put into models/*.dart
.
Author by
Vega180
Updated on December 29, 2022Comments
-
Vega180 over 1 year
Is there a best practice for the location of custom helper classes in Flutter using BLoC architecture?
This is my package structure:
/data /data_providers /models /repositories /logic /blocs /cubits /presentation /screens /widgets /resources
Example: I have a custom helper class
Tuple
which is only used in my model/data/models/User.dart
.I see the following options:
- place class
Tuple
above or below classUser
in/data/models/User.dart
- create the file
/data/models/Tuple.dart
and place classTuple
there - create the new package
/helpers
in the root directory, create the file/helpers/Tuple.dart
and place classTuple
there - or do you have other recommendations?
Of course all solutions are functionable. The question is: What is best practice?
-
ch271828n almost 3 yearshi, if you think my answer is useful, please click the "accept the answer"; if no, please give some explanations
- place class