aChat – Flutter Firebase Chat and Messenger Documentation

  1. Home
  2. Docs
  3. aChat – Flutter Firebase Chat and Messenger Documentation
  4. File Structure & Architecture

File Structure & Architecture

File Structure

├── README.md
├── android
├── ios
├── assets
│ ├── i18n
│ │ ├── de.json
│ │ ├── en.json
│ │ ├── es.json
│ │ ├── fa.json
│ │ └── ru.json
│ └── images
│ ├── avatar.jpg
│ └── logotype.png
├── lib
│ ├── constants.dart
│ ├── main.dart
│ ├── screens
│ │ ├── chat_screen.dart
│ │ ├── chats_screen.dart
│ │ ├── common_screen.dart
│ │ ├── contacts_screen.dart
│ │ ├── language_screen.dart
│ │ ├── login_screen.dart
│ │ ├── registration_screen.dart
│ │ ├── reset_password.dart
│ │ ├── settings_screen.dart
│ │ └── welcome_screen.dart
│ ├── services
│ │ ├── chat_arguments.dart
│ │ └── helpers.dart
│ └── test.dart
├── pubspec.lock
└── pubspec.yaml

 Architecture

We used the standard Flutter application architecture based on the basic State management using setState(). And for data transfer, the application uses asynchronous Streams.

The standard approach does not bind the developer to a specific state manager and architecture.

And also allows you to implement any preferred approach and management for example: Provider, Bloc, MVC, etc …

 

Thorough the app structure:

  • lib directory – contains screens and services
    • main.dart – contains the application init, localization is implemented, navigation (routing) is scheduled, the application theme (theming) is initialized.
    •  constants.dart  – contains constants for Theme Data, based on the material design theming. Variables such as fonts, colors, and sizes.
    • screens directory – contains all app screens. The code for each screen is divided into main blocks:
      • 1. First comes a list of imported libraries and packages used on the screen
      • 2. Then comes the main widget of the screen itself
      • 3. Below are the other helper components (widgets) for the screen
      • Each widget is divided into semantic blocks and marked with comments:
      • 1. Variables – the first block at the beginning of each widget in which all used variables are declared.
      • 2. Functions & Methods – a block with functions and methods, as well as initialization of states used in the current widget.
      • 3. Build Widget – The main Method for building a widget.widget comments structure
    • services directory – contains helpers functions & classes
      • chat_arguments.dart – contains helper classes for storing and transmitting data.
      • helpers.dart – contains helper functions used in screens and widgets, like converting other types of data, etc.
  • assets directory
    • i18n directory – contains JSON localization files
    • images directory – local images.
  • pubspec.yaml – contains constants used for Theme Data, based on material design. Variables such as fonts, colors, sizes.

Libraries in pubspec.yaml

name: a_chat
description: AChat material flutter chat application based on FireBase

version: 1.0.0+1

environment:
  sdk: ">=2.1.0<3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  flutter_translate: ^1.6.0
  firebase_core: ^0.4.4+3
  cupertino_icons: ^0.1.2
  firebase_auth: ^0.16.0
  cloud_firestore: ^0.13.5
  modal_progress_hud: ^0.1.3
  intl: ^0.16.1
  firebase_messaging: ^6.0.16
  flutter_local_notifications: ^1.4.3
  cached_network_image: ^2.2.0+1
  firebase_storage: ^3.1.6
  image_picker: ^0.6.7
  fluttertoast: ^4.0.1
  badges: ^1.1.1
  introduction_screen: ^1.0.7
  shared_preferences: ^0.5.7+3


dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
  - assets/images/
  - assets/i18n/

 

Was this article helpful to you? Yes No

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *