Combining multiple different flutter projects

Viewed 2908

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 Answers

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.

Related