So I have received a project which requires e-commerce, food ordering and car hailing services like Grab to be inside one app. I have delivered all these 3 apps in different projects before and for this new project I'm wondering whether it is possible to combine all my previous source code into one project, running on different dependencies.
1 Answer
You can create packages for all 3 modules (food, e-commerce, car-hailing services)
To create a Flutter package, use the --template=package flag with flutter create:
flutter create --template=package food
Folder Structure
lib
packages
- food
- e_commerce
- car_hailing_service
Import this in the main module's pubspec.yaml file
dependencies:
flutter:
sdk: flutter
# My Custom Packages
food:
path: packages/food
e_commerce:
path: packages/e_commerce
car_hailing_service:
path: packages/car_hailing_service
If you have any common functionalities for all 3 packages then create a separate package for that also and import that common package for all 3 packages.
Refer to this document for creating flutter packages. I hope this helps you.
8 Comments
Randal Schwartz
Or if you want separate examples and testing suites, move it up a level, and use
path: ../packages/food. You can also eventually publish one of the packages to pub if you want.emily
I've created modules for these three and have moved the project files into them. I can navigate to those project screens without any problem. However, the providers that are used in the projects don't seem working. Do I have to move all providers to the main.dart in parent lib folder?
Vinoth
Yes, if you want that provider for all 3 modules then move that provider to main module.
Vinoth
I'm happy to help! @emily
Bhargav Sejpal
how navigation will work in such case ?
|