/electrometer

A companion app made in Flutter to be used with my LoRA-WAN Electro meter project. Utilizes Firebase with Firestore as the backend with BLoC/MVVM Architecture pattern.

Primary LanguageJavaScriptMIT LicenseMIT

Electrometer

coverage style: very good analysis License: MIT

A companion app to be used with my LoRA-WAN Electro meter project.


Getting Started πŸš€

This project contains 3 flavors:

  • development
  • staging
  • production

To run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands:

# Development
$ flutter run --flavor development --target lib/main_development.dart

# Staging
$ flutter run --flavor staging --target lib/main_staging.dart

# Production
$ flutter run --flavor production --target lib/main_production.dart

*Electrometer works on iOS, Android, and Web.


Running Tests πŸ§ͺ

To run all unit and widget tests use the following command:

flutter test --coverage --test-randomize-ordering-seed random

To view the generated coverage report you can use lcov.

# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
$ open coverage/index.html

Working with Translations 🌐

This project relies on flutter_localizations and follows the official internationalization guide for Flutter.

Adding Strings

  1. To add a new localizable string, open the app_en.arb file at lib/l10n/arb/app_en.arb.

    {
        "@@locale": "en",
        "counterAppBarTitle": "Counter",
        "@counterAppBarTitle": {
            "description": "Text shown in the AppBar of the Counter Page"
        }
    }
    
  2. Then add a new key/value and description

    {
        "@@locale": "en",
        "counterAppBarTitle": "Counter",
        "@counterAppBarTitle": {
            "description": "Text shown in the AppBar of the Counter Page"
        },
        "helloWorld": "Hello World",
        "@helloWorld": {
            "description": "Hello World Text"
        }
    }
    
  3. Use the new string

    import 'package:electrometer/l10n/l10n.dart';
    
    @override
    Widget build(BuildContext context) {
    final l10n = context.l10n;
    return Text(l10n.helloWorld);
    }

Adding Supported Locales

Update the CFBundleLocalizations array in the Info.plist at ios/Runner/Info.plist to include the new locale.

    ...

    <key>CFBundleLocalizations</key>
    <array>
    <string>en</string>
    <string>es</string>
    </array>

    ...

Adding Translations

  1. For each supported locale, add a new ARB file in lib/l10n/arb.

    β”œβ”€β”€ l10n
    β”‚   β”œβ”€β”€ arb
    β”‚   β”‚   β”œβ”€β”€ app_en.arb
    β”‚   β”‚   └── app_es.arb
  2. Add the translated strings to each .arb file:

    app_en.arb

    {
        "@@locale": "en",
        "counterAppBarTitle": "Counter",
        "@counterAppBarTitle": {
            "description": "Text shown in the AppBar of the Counter Page"
        }
    }
    

    app_es.arb

    {
        "@@locale": "es",
        "counterAppBarTitle": "Contador",
        "@counterAppBarTitle": {
            "description": "Texto mostrado en la AppBar de la pΓ‘gina del contador"
        }
    }
    

Flutter Doctor Output

[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1645], locale en-IN)
    β€’ Flutter version 2.10.5 at D:\flutter
    β€’ Upstream repository https://github.com/flutter/flutter.git
    β€’ Framework revision 5464c5bac7 (2 weeks ago), 2022-04-18 09:55:37 -0700
    β€’ Engine revision 57d3bac3dd
    β€’ Dart version 2.16.2
    β€’ DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    β€’ Android SDK at D:\androidsdks
    β€’ Platform android-31, build-tools 30.0.2
    β€’ ANDROID_SDK_ROOT = D:\androidsdks
    β€’ Java binary at: D:\Program Files\JetBrains\apps\AndroidStudio\ch-0\193.6626763\jre\bin\java
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    β€’ All Android licenses accepted.

[√] Chrome - develop for the web
    β€’ Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.3)
    β€’ Visual Studio at D:\Program Files\Visual Studio
    β€’ Visual Studio Community 2019 version 16.8.30804.86
    β€’ Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.0)
    β€’ Android Studio at D:\Program Files\JetBrains\apps\AndroidStudio\ch-0\193.6626763
    β€’ Flutter plugin version 51.0.1
    β€’ Dart plugin version 193.7547
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Ultimate Edition (version 2020.2)
    β€’ IntelliJ at D:\Program Files\JetBrains\apps\IDEA-U\ch-0\202.6397.94
    β€’ Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    β€’ Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.66.2)
    β€’ VS Code at C:\Users\dhi13man\AppData\Local\Programs\Microsoft VS Code
    β€’ Flutter extension version 3.38.1

[√] Connected device (3 available)
    β€’ Windows (desktop) β€’ windows β€’ windows-x64    β€’ Microsoft Windows [Version 10.0.19044.1645]
    β€’ Chrome (web)      β€’ chrome  β€’ web-javascript β€’ Google Chrome 100.0.4896.127
    β€’ Edge (web)        β€’ edge    β€’ web-javascript β€’ Microsoft Edge 100.0.1185.50

[√] HTTP Host Availability
    β€’ All required HTTP hosts are available

β€’ No issues found!