/isar_sandbox

Primary LanguageDartMIT LicenseMIT

Isar Sandbox

coverage style: very good analysis License: MIT

πŸ€– Generated via Riverpod Core Brick

Testing Isar


Usage πŸ’―

Before anything, run:

flutter pub get

This project exploits code generation extensively.
Before anything, you need to run build_runner at least once before launching this application:

flutter pub run build_runner build -d

Wait until this process is done. It can even take a few minutes.

Supported platforms

This application currently supports the following platforms: android,linux.

Dev server

Since this application uses flavors, you can't just use 'flutter run`.
When you're ready to see this application in action (dev server), you can run:

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

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

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

And look at this software go!

Build

Building an application can be done through flutter build, but it's recommended to set up a CI/CD tool before releasing a staging or a production-ready executable.


Internals βš™οΈ

A few notes about this Software.

Flavoring

This project contains 3 flavors:

  • development
  • staging
  • production

Architecture

This project uses well-known Clean Architecture principles, with a pinch of pragmatism.

Libraries

Here's a quick recap of the libraries used in this project:

  • hooks_riverpod as state management / caching / DI solution
  • riverpod_generator to supercharge riverpod
  • freezed to generate data classes.
  • flutter_hooks to easily handle ephimeral state
  • riverpod_lint for a set of great riverpod-related lints
  • very_good_analysis for a set of well-known lints

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"
    }
}
  1. 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": "New Hello World Text"
    }
}
  1. Use the new string
import 'package:isar_sandbox/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
  1. 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"
    }
}

Generating Translations

To use the latest translations changes, you will need to generate them:

  1. Generate localizations for the current project:
flutter gen-l10n --arb-dir="lib/l10n/arb"

Alternatively, run flutter run and code generation will take place automatically.

isar_sandbox