9

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 1

7

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.

Sign up to request clarification or add additional context in comments.

8 Comments

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.
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?
Yes, if you want that provider for all 3 modules then move that provider to main module.
I'm happy to help! @emily
how navigation will work in such case ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.