Flutter template project - Simple ToDo app with scalable project structure.

Overview

Flutter Template

Flutter template project - A simple TODO list app. This template provides simple UI and scalable project structure that goes beyond the simple counter example.

The app has basic login and signup screens, task list, task details, and settings screen. It supports multiple languages and in-app language change, and light and dark theme.

It's configured with BLoC for state management, Chopper for networking, Navigation 2.0, GetIt as service locator, UserManager, Repository Pattern, Logger, and util and convenience methods.


    Light theme      Dark theme

First Run

The project is configured with mock data if you run the MOCK flavor. See the next section for configuring run configurations.

After installing the package dependencies with

flutter pub get

run the code generation tool

flutter pub run build_runner build

Run Configurations

In addition to the Flutter's build modes (debug, profile, release), the project has 4 flavours/schemas for defining environments:

  • mock - mock environment that uses mock values. Launches main_mock.dart
  • dev - development environment that targets a development server. Launches main_dev.dart
  • staging - staging environment that targets a staging server. Launches main_staging.dart
  • production - production environment that targets a production server. Launches main_production.dart

To run the app use the following command:

flutter run --flavor dev -t lib/main_dev.dart

or edit run configurations in Android Studio:

  • Go to EditConfigurations...
  • Enter configuration name: DEV, STAGE, PROD
  • Enter dart entry point: main_dev.dart, main_staging.dart, main_production.dart
  • Enter additional run args: --flavor=dev, --flavor=staging, --flavor=production
  • Enter build flavor: dev, staging, production

See flavor_config.dart for environment specific config.

For adding an additional Flutter flavours see the official documentation and this blog post.

Use as template

You can copy this repository with the Use this template button and go on from there, or download the code and use it in you project. Afterwards, you'll need to rename the project and change the app id and configuration. There are ToDos scattered through the project that will help you transition this project to your needs.

Use as template

Head to the Wiki page for project documentation.

Resolve TODOs

Go over the TODOs scattered around the project and resolve as much as possible. They will help you configure the project to your needs.

In AndroidStudio you can view all TODOs in the bottom tab as shown in this picture:

TODOs bottom tab in AS

App Configuration

To configure the app for your environment head to the /config directory:

  • add flavor-specific valus in FlavorConfig -> FlavorValues
  • configure firebase in FirebaseConfig, duh
  • configure API constants in network_constants
  • also see pre_app_config and post_app_config for preloading essential app components

See the wiki configuration page for more info.

Under the hood

Data Management

Alt text

TasksDataSource

This is the main entry point for accessing and manipulating tasks data. The rest of the app should not invoke tasks' endpoints directly or query cached data. All tasks operations should go through this service.

Implementations:

  • TasksRemoteDataSource - Uses the ApiService to contact a remote server;
  • TasksCacheDataSource - Uses in-memory cache to retrieve tasks;
  • TasksRepository - Uses both TasksRemoteDataSource and TasksCacheDataSource to fetch cached data when available; Provides subscription for updates;

ApiService

Abstraction over the API communication that defines (all) endpoints. This templates uses Chopper, an http client generator, to make network requests.

JSON and Serialization

JSON models are serialized using a code generation library.

For one time code generation run this command in terminal: flutter pub run build_runner build

For subsequent code generations with conflicting outputs: flutter pub run build_runner build --delete-conflicting-outputs

For more information and generating code continuously see the documentation.

Declarative UI and state management

Flutter is declarative framework. This means that Flutter builds its user interface to reflect the current state of the app.

High level diagram

This template attempts to be unopinionated and does not yet use a state management tool. ...we use BLoC now. But, each app service has an updates Stream that clients can subscribe to and receive state updates. See the UpdatesStream mixin. It's up to you to use a tool of your choice, or don't use one at all. See TasksRepository#taskEventUpdatesStream and TasksRepository#taskGroupUpdatesStream in TasksRepository

Dependency Management

Dependencies are managed in the service_locator.dart file. This sample uses GetIt, a lightweight service locator. There are 2 scopes defined in this template global and user scope. For more information visit the wiki service locator page.

Logger

This project uses a custom Logger configured to:

  1. print to console, except in production
  2. write to a file, except in production - useful for QA reporting
  3. log to firebase or report a non-fatal error to firebase

Prefer to use this logger over print statements.

  • Log.d(message) for debug messages
  • Log.w(message) for warning messages
  • Log.e(object) for error messages (this will also report a firebase non-fatal error)

Tests

The test package contains unit tests for almost all components. Be sure to give it a look.

Comments
  • bloc

    bloc

    guys nice project but after I review the code its seems like its not fully bloc. for example usermanager.. the programming community past the period of "managers" and also use it as a global listener and singleton its not good idea.

    here is dummy example for authentication https://github.com/TaeBbong/bloc_login

    opened by dvird 1
  • [Question} - Bottom navigation

    [Question} - Bottom navigation

    First of all, thanks for the template. I was wondering if there is a chance to provide us an example with BottomNavigation.

    Already did something, but the main problem for me is navigating between tabs and showing correct state of the back button.

    For example, when I navigate to "Home" tab, back button is visible. Should I use nested navigation per each tab?

    Would be curious to hear from you .

    Thanks again. Simulator Screen Shot - iPhone 12 Pro Max - 2021-07-19 at 00 13 29

    opened by ArbenMaloku 1
  • Pre-commit hooks

    Pre-commit hooks

    It would be nice to have a pre-commit hook already set up.

    flutter format .to assure the style of the code.

    flutter analyze to analyze our dart code.

    flutter test to run our unit tests.

    Take a look at: Flutter pre-commit hook gist

    enhancement 
    opened by Mar1anne 0
  • Upgrade dependencies

    Upgrade dependencies

    The following warnings are generated:

    /Users/wf-marianaristovska/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.4.0/ios/Classes/FlutterWebView.m:524:23: warning: 'requiresUserActionForMediaPlayback' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
                configuration.requiresUserActionForMediaPlayback = true;
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              mediaTypesRequiringUserActionForPlayback
        In module 'WebKit' imported from /Users/wf-marianaristovska/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.4.0/ios/Classes/FlutterWebView.h:6:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebViewConfiguration.h:218:28: note: 'requiresUserActionForMediaPlayback' has been explicitly marked deprecated here
        @property (nonatomic) BOOL requiresUserActionForMediaPlayback API_DEPRECATED_WITH_REPLACEMENT("mediaTypesRequiringUserActionForPlayback", ios(9.0, 10.0));
                                   ^
        /Users/wf-marianaristovska/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.4.0/ios/Classes/FlutterWebView.m:536:23: warning: 'requiresUserActionForMediaPlayback' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
                configuration.requiresUserActionForMediaPlayback = false;
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              mediaTypesRequiringUserActionForPlayback
        In module 'WebKit' imported from /Users/wf-marianaristovska/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.4.0/ios/Classes/FlutterWebView.h:6:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebViewConfiguration.h:218:28: note: 'requiresUserActionForMediaPlayback' has been explicitly marked deprecated here
        @property (nonatomic) BOOL requiresUserActionForMediaPlayback API_DEPRECATED_WITH_REPLACEMENT("mediaTypesRequiringUserActionForPlayback", ios(9.0, 10.0));
                                   ^
    

    flutter pub outdated gives the following output:

    /Users/wf-marianaristovska/flutter/bin/flutter --no-color pub outdated
    Showing outdated packages.
    [*] indicates versions that are not the latest available.
    
    Package Name                                    Current   Upgradable  Resolvable  Latest   
    
    direct dependencies:                           
    chopper                                         *4.0.6    *4.0.6      5.1.0       5.1.0    
    firebase_analytics                              *9.3.8    *9.3.8      10.0.6      10.0.6   
    firebase_core                                   *1.24.0   *1.24.0     2.3.0       2.3.0    
    firebase_crashlytics                            *2.9.0    *2.9.0      3.0.6       3.0.6    
    firebase_messaging                              *11.4.4   *11.4.4     14.1.1      14.1.1   
    flutter_local_notifications                     *9.9.1    *9.9.1      12.0.4      12.0.4   
    permission_handler                              *8.3.0    *8.3.0      10.2.0      10.2.0   
    webview_flutter                                 *2.8.0    *2.8.0      3.0.4       3.0.4    
    
    dev_dependencies:                              
    build_runner                                    *2.3.0    *2.3.0      *2.3.0      2.3.2    
    chopper_generator                               *4.0.6    *4.0.6      5.1.0+1     5.1.0+1  
    
    transitive dependencies:                       
    _flutterfire_internals                          *1.0.2    *1.0.2      1.0.9       1.0.9    
    async                                           *2.9.0    *2.9.0      *2.9.0      2.10.0   
    boolean_selector                                *2.1.0    *2.1.0      *2.1.0      2.1.1    
    cloud_firestore_platform_interface              *5.7.7    *5.7.7      5.9.0       5.9.0    
    cloud_firestore_web                             *2.8.10   *2.8.10     3.1.0       3.1.0    
    collection                                      *1.16.0   *1.16.0     *1.16.0     1.17.0   
    file                                            *6.1.2    *6.1.2      *6.1.2      6.1.4    
    firebase_analytics_platform_interface           *3.3.7    *3.3.7      3.3.14      3.3.14   
    firebase_analytics_web                          *0.4.2+7  *0.4.2+7    0.5.1+5     0.5.1+5  
    firebase_core_web                               *1.7.3    *1.7.3      2.0.1       2.0.1    
    firebase_crashlytics_platform_interface         *3.3.0    *3.3.0      3.3.7       3.3.7    
    firebase_messaging_platform_interface           *3.5.4    *3.5.4      4.2.7       4.2.7    
    firebase_messaging_web                          *2.4.4    *2.4.4      3.2.7       3.2.7    
    flutter_local_notifications_linux               *0.5.1    *0.5.1      2.0.0       2.0.0    
    flutter_local_notifications_platform_interface  *5.0.0    *5.0.0      6.0.0       6.0.0    
    flutter_secure_storage                          *5.1.2    *5.1.2      *5.1.2      6.0.0    
    js                                              *0.6.4    *0.6.4      *0.6.4      0.6.5    
    matcher                                         *0.12.12  *0.12.12    *0.12.12    0.12.13  
    material_color_utilities                        *0.1.5    *0.1.5      *0.1.5      0.2.0    
    permission_handler_android                      -         -           10.2.0      10.2.0   
    permission_handler_apple                        -         -           9.0.7       9.0.7    
    permission_handler_windows                      -         -           0.1.2       0.1.2    
    source_span                                     *1.9.0    *1.9.0      *1.9.0      1.9.1    
    stack_trace                                     *1.10.0   *1.10.0     *1.10.0     1.11.0   
    stream_channel                                  *2.1.0    *2.1.0      *2.1.0      2.1.1    
    string_scanner                                  *1.1.1    *1.1.1      *1.1.1      1.2.0    
    test_api                                        *0.4.12   *0.4.12     *0.4.12     0.4.16   
    timezone                                        *0.8.0    *0.8.0      0.9.0       0.9.0    
    vector_math                                     *2.1.2    *2.1.2      *2.1.2      2.1.4    
    xml                                             *6.1.0    *6.1.0      *6.1.0      6.2.2    
    
    transitive dev_dependencies:                   
    _fe_analyzer_shared                             *47.0.0   *47.0.0     *47.0.0     50.0.0   
    analyzer                                        *4.7.0    *4.7.0      *4.7.0      5.2.0    
    archive                                         *3.3.0    *3.3.0      *3.3.0      3.3.5    
    build_resolvers                                 *2.0.10   *2.0.10     *2.0.10     2.1.0    
    coverage                                        *1.5.0    *1.5.0      *1.5.0      1.6.1    
    frontend_server_client                          *2.1.3    *2.1.3      *2.1.3      3.1.0    
    glob                                            *2.1.0    *2.1.0      *2.1.0      2.1.1    
    test                                            *1.21.4   *1.21.4     *1.21.4     1.22.0   
    test_core                                       *0.4.16   *0.4.16     *0.4.16     0.4.20   
    vm_service                                      *9.0.0    *9.0.0      *9.0.0      9.4.0    
    webdriver                                       *3.0.0    *3.0.0      *3.0.0      3.0.1    
    
    21  dependencies are constrained to versions that are older than a resolvable version.
    To update these dependencies, edit pubspec.yaml, or run `flutter pub upgrade --major-versions`.
    Process finished with exit code 0
    
    opened by Mar1anne 1
  • Splash screen

    Splash screen

    hi you are loading all the pre work of the app before the app loaded.

    ` await preAppConfig();

    BlocOverrides.runZoned(() => runApp(App()), blocObserver: BlocEventsLogger());`

    in case of no internet or another problem the user will be stuck on the splash screen without option to get out of it.

    you can check this library which gives better docs and explanation on flutter splash https://pub.dev/packages/flutter_native_splash

    opened by dvird 0
  • Fix DataNotificationManager documentation

    Fix DataNotificationManager documentation

    This documentations contains false information(and it can be misleading) for example: /// To obtain an instance use serviceLocator.get<NotificationsManager>()

    This is not correct and should be /// To obtain an instance use serviceLocator.get<NotificationsConsumer>()

    Also we should register DataNotificationManager instance with the serviceLocator..

    If we implement this changes please consider changing the logs inside DataNotificationManager that contains: NotificationManager into NotificationConsumer..

    opened by petrovWF 0
Owner
Web Factory LLC
Web Factory LLC
This is template toolkit fasten your project setup within a minute. The toolkit is based on MVC+S structure.

BWeird Flutter Toolkit! Hi! From a Weirder Flutter has been great on mobile development and I took this opportunity to make it even greater with templ

Setak Varaman !!!! 6 Aug 22, 2021
Flutter ToDo App - A simple ToDo App made with Flutter and Hive

Flutter ToDo App A simple ToDo App made with Flutter and Hive. ✨ Features Create,Delete,Update tasks. Create Subtasks. Star important Tasks. ?? Screen

null 3 Aug 4, 2022
Todo app codelab - A simple UI for todo app to showcase Flutter features and core concepts

Codelab Todo App A simple todo app UI for to showcase Flutter and Dart core conc

Junior Medehou 3 May 12, 2022
Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.

supabase_flutter Flutter package for Supabase. What is Supabase Supabase is an open source Firebase alternative. We are a service to: listen to databa

Supabase 251 Jan 7, 2023
Flutter App Templete is a project that introduces an approach to architecture and project structure for developing Flutter apps.

Flutter App Template "Flutter App Template" is a project that introduces an approach to architecture and project structure for developing Flutter apps

Altive 126 Jan 5, 2023
Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to developing Flutter apps.

Flutter Architecture Blueprints Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to dev

Katsuyuki Mori 2 Apr 9, 2022
Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to developing Flutter apps.

Flutter Architecture Blueprints Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to dev

Daichi Furiya 1.5k Dec 31, 2022
A fast start flutter project to make aps faster and skip setup on every application. I am personally using this structure while creating a new project

Flutter Fast Start A fast start flutter project to make apps faster and skip setup on every application. I am personally using this structure while cr

Okan Demir 2 Dec 15, 2022
A modular app architecture that can be scalable as the time passes

A modular app architecture that can be scalable as the time passes. I will be using the BLoC state-management package.

Md. Siam 62 Dec 25, 2022
Flutter package for displaying and animating Scalable Vector Graphics 1.1 files. The package has been written solely in Dart Language.

Animated SVG | Flutter Package Flutter package for displaying and animating Scalable Vector Graphics 1.1 files. The package has been written solely in

Bulent Baris Kilic 5 Jul 19, 2022
Dartness is a progressive dart framework for building efficient and scalable server-side applications

Dartness is a framework for building efficient, scalable dart server-side applications. It provides an easy and quick way to develop modern standalone server.

Ricardo Romero 33 Dec 12, 2022
🦜 Parrot - A progressive Dart framework for building efficient, reliable and scalable server-side applications.

?? Parrot A progressive Dart framework for building efficient, reliable and scalable server-side applications. What is Parrot? Parrot is a Dart framew

Odroe 8 Nov 11, 2022
Flutter getx template - A Flutter Template using GetX package for State management, routing and Dependency Injection

Flutter GetX Template (GetX, Dio, MVVM) This Flutter Template using GetX package

Tareq Islam 6 Aug 27, 2022
meg4cyberc4t 11 Oct 24, 2022
Project Structure Auth Generator For Flutter

get_structure_generator Project Structure Auto Generator This is not the package

Mitul Vaghasiya 6 Mar 22, 2022
Emanuel Braz 27 Dec 22, 2022
A flutter demo app to practice Map data structure and its common operations

Map Operations A flutter demo app to practice Map data structure and its common operations Developer Alexander Sosa (https://www.linkedin.com/in/alexa

Alexander Sosa 0 Jan 3, 2022
A movies app made with Flutter focused on solid software structure patterns.

Flutter Movies App An application made with Flutter to practice the principles of Clean Architecture. Even being focused on architecture, the project

Márcio Valim 59 Dec 12, 2022
Flutter-Wings - This is a structure for flutter developers developed by Invention Technology.

Flutter : Wings File Structure About Wings installation simple use Advance Use About Wings Wings is an MVC file structure build with getx for flutter

Invention Technology 20 Nov 20, 2022