Skip to main content

Flutter Factory - A CLI for Creating Flutter Projects

Nicolas Schlecker 4 min read
Flutter Factory - A CLI for Creating Flutter Projects

Flutter Factory - The easiest way to manage Flutter projects with Dart

English Version on Medium

In April 2019, we had the opportunity to develop the official app for our local ice hockey team, the Starbulls Rosenheim. (Available for iOS and Android)

During the research for the project, we came across the then still small cross-platform framework Flutter. To say that Flutter was a bit different at the time would be an understatement. Brilliant libraries like flutter_bloc and sqfentity didn’t exist yet, and we basically had to start from scratch. This process of developing almost every small part of the app from the ground up was very long and exhausting.

We have been using Flutter as our primary framework for app development for over a year now, and during this time, we have learned more and more. Now we have decided to invest the time and resources to develop a template and an accompanying CLI that will help us give the development process a speed boost at the start of every project. The open source projects flutter-factory and flutter-factory-templates were born.

Okay, cool story. What exactly is this and what does it do for me?

flutter-factory is a CLI. Its main task is to create new Flutter projects and configure them automatically. Essentially, it takes care of all the boring steps at the beginning of every new project. The basis for all new projects is:

flutter-factory-templates a Flutter template that contains (almost) everything every app needs. Including:

  • State management using the latest and greatest version of flutter_bloc
    • A Todo example is also included to better understand the bloc pattern
  • Complete Firebase authentication flows including ready-made views for creating an account, logging in, and login with Apple, Google, and Facebook is also supported.
    • If you don’t want to configure these third-party providers yourself, you can simply use
      $ flutter-factory auth and the CLI will guide you through a simple configuration process.
  • Firebase Messaging integration for push notifications - in-app notifications are also included!
  • Firebase Remote Config and local configuration are also supported.

To summarize, flutter-factory makes your life easier and the development process faster.

Got it. Pretty cool. How do I use it?

First, you need to install the CLI. This is easily done with:

$ npm i -g flutter-factory (Additionally, git and firebase-tools must be installed.)

And now you’re just one command away from a fully equipped app. Simply enter

$ flutter-factory create

and the CLI will guide you through setting up the app. Firebase is automatically configured!

Wait, there’s more!

In addition to the create command, there are other things the CLI can help with. For example, there is the command

$ flutter-factory rename

This can be run in any Flutter project to rename not only the Flutter project itself (i.e., the Dart package) but also the Android package and the iOS bundle identifier.

As mentioned above in the template features, there is also the

$ flutter-factory auth

command, which makes it easy to configure third-party authentication providers.

To create a Firebase project or just add one to an app, there is

$ flutter-factory firebase

This command lets you choose from a list of your Firebase projects or create a new one and then adds it to your Flutter project. Additionally, the two configuration files for iOS and Android are downloaded and placed directly in the corresponding folders.

What’s under the hood?

The CLI is written in TypeScript and is built on commander.js. All user inputs are processed with inquirer, and the colorful display comes from chalk. Everything related to Firebase uses your local installation of firebase-tools. Additionally, all the code of the CLI and the template is open source and available for viewing at any time.

We hope that flutter-factory becomes an important tool in your Flutter repertoire and helps you with both new and existing Flutter projects! If you like the project, give us a star on GitHub - it doesn’t cost anything after all.

Written by Nicolas Schlecker Business Unit Director

Software Developer bei innFactory mit Fokus auf moderne Frontend-Technologien.