cingulo / Flutter Sample
Programming Languages
Labels
Projects that are alternatives of or similar to Flutter Sample
Cíngulo Flutter Sample
Warning / Deprecated
I currently discourage discourage the usage of this architecture. These are some of the main reasons, also serving as a north about what to do:
- I think life can be easier by using MobX instead of BLoC.
- inject.dart still hasn't been published, prefer GetIt but notice that they are different things (injector vs service locator).
- Refactor the remaining singleton intances (app bloc, error, services) to not be singletons. Use GetIt and create a service locator for them. This will make testing easier.
- The auth and accounts repository are a little messy, code can be even simpler and cleaner on them.
About
Working with Flutter 1.12.13+hotfix.5
Status | develop |
---|---|
Travis CI | |
Coveralls |
Check out a short demo video here.
Check out some screenshots here.
A fully working sample Flutter app implementation. Give this repo a Star if you like it :)
- Layers separation (data, domain, logic, ui)
- Network calls and very simple caching and concurrency mechanism
- Generic error handling
- Forms validation
- Generic bloc structure
- RxDart
- Dependency injection
- Authentication with JWT and daily renewal (simple, no distinct access/refresh or sliding tokens).
- Themes
- Multiple languages
- Named routes
- Named routes with parameters
- Names routes with simple permission control
- Analytics and pushes skeleton
- We have published the API so that you can test the app
- Looks good but... it is still missing tests (TODO) :(
Dependency Injection
This project uses inject.dart. We only had to fork it from Google in order to bump a version dependency. You will have to clone it under vendor/inject.dart:
$ cd <repository-root>
$ git clone https://github.com/cingulo/inject.dart.git vendor/inject.dart
Use the commands below to build the dependency injection:
$ flutter packages pub run build_runner build --build-filter "lib/data/*/*.dart" --delete-conflicting-outputs
$ flutter packages pub run build_runner build --build-filter "lib/app/*.dart" --delete-conflicting-outputs
- Done, you should now be good to run the app.
Structure
-
app/
Where the starting MaterialApp resides. -
common/
Abstract app-wide base classes. -
data/
Data handling. -
data/*_repository.dart
Frontier between app models and data storage. -
errors/
Custom app errors. -
models/
App models, independent of howdata/*_repository.dart
handles it (db, api, file, in memory, etc). -
screens/
App screens, may also have screen-specific sub widgets. -
screens/*_bloc.dart
Screen/widget business logic. -
services/
App-wide logic like analytics, crashes, l10n, pushes, refresh and routes. -
themes/
App themes. -
widgets/
App-wide widgets. Design system components would reside here, for example. -
env.dart
Envs. -
main.dart
Entry point.
Routes
Routes must be instantiated here to be available for navigation.
L10n
L10n delegates must be listed here to be available.
API Docs
Open the docs URL in your browser. You can also check the API GitHub repository.