psatler / flutter-clean-architecture

A survey app developed with clean architecture and SOLID principles in mind

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub top language GitHub language count Repository size Repository Last Commit Date Made by Pablo Satler License

CI Workflow

Flutter Clean Architecture

A survey app developed with clean architecture and SOLID principles in mind

Table of Contents

Table of Contents

Version

This was originally built using Flutter 1.22.6 and on March 3rd was upgraded to Flutter 2.0.0. Though, the code was not migrated to null safety yet.

Back to top

Backend

The swagger documentation for the backend the app communicate with can be found here

Back to top

Third party packages

Dependencies

  • Meta: Annotations for Static Analysis
  • Http: A composable, Future-based library for making HTTP requests.
  • Provider: A wrapper around InheritedWidget to make them easier to use and more reusable.
  • Equatable: An abstract class that helps to implement equality without needing to explicitly override == and hashCode.
  • Get: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
    • Pay attention that I'm using version 3.4.2 exactly.
  • Flutter Secure Storage: provides API to store data in secure storage. Keychain is used in iOS, KeyStore based solution is used in Android.
    • We need to modify the minSdkVersion to 18 in the build.gradle file in the Android project
  • Local Storage: Simple json file-based storage for flutter
  • Carousel Slider: A carousel slider widget.
  • Intl: Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization issues.
    • Used in this project for Date conversions.

Dev Dependencies

  • Test: provides a standard way of writing and running tests in Dart.
  • Mockito: Mock library for Dart inspired by the Java's Mockito library.
    • Instructions on how to mock using Null Safety can be find here.
    • To run the build_runner, we do flutter pub run build_runner build.
    • an alternative to Mockito for null safety is Mocktail with no need to code-generation.
  • Faker: A library for Dart that generates fake data.
  • Network Image Mock: Utility for providing mocked Image.network response in Flutter widget tests.
    • the widget Image.network will throw an exception if we run them on tests. This library helps us mocking them.
    • another library the does the same but for the Mocktail test library is mocktail_image_network.
  • Flutter Launcher Icons: A command-line tool which simplifies the task of updating your Flutter app's launcher icon. More complex settings with flavors can be found here.
    • the configuration done can be found at the end of the pubspec.yaml file.
    • more pieces of information about adaptive icons can be found here.
    • you need to run the command specified in the library's docs: flutter pub run flutter_launcher_icons:main

Back to top

Screens

Login and SignUp

flutter flutter flutter flutter

Surveys

Answered and not already answered.

flutter flutter

Survey results

flutter flutter

Back to top

VSCode configurations

On the Run tab at the left side you can create a launch.json configuration to run the application as well as their tests. You can add default configuration too, such as Flutter run all tests, so you can run all the tests by pressing F5.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Flutter: Run all Tests",
      "type": "dart",
      "request": "launch",
      "program": "./test/"
    },
    {
      "name": "flutter_clean_arch",
      "request": "launch",
      "type": "dart",
      "program": "./lib/main/main.dart"
    }
  ]
}
Snippets

Also, it was created a snippets to help initialize the boilerplate for tests. To create a snippet, goes to File -> Preferences -> User Snippets and then create a dart.json file. The snippet create use darttest as a shortcut.

{
  "Dart unit tests": {
		"prefix": "darttest",
		"body": [
			"import 'package:test/test.dart';",
			"",
			"void main() {",
			" test('', () {});",
			"}"
		],
		"description": "Initial boilerplate for Dart test code"
	},
	"Flutter Widget tests": {
		"prefix": "fluttertest",
		"body": [
			"import 'package:flutter_test/flutter_test.dart';",
			"",
			"void main() {",
			" testWidgets('', (WidgetTester tester) async {",
			"",
			" });",
			"}"
		],
		"description": "Initial boilerplate for Flutter Wiget test"
	},
}

Back to top

Aknowledgements

Back to top

License

This project is licensed under the terms of the MIT License © Pablo Satler 2021

Back to top

About

A survey app developed with clean architecture and SOLID principles in mind

License:MIT License


Languages

Language:Dart 98.7%Language:Gherkin 1.1%Language:Swift 0.2%Language:Kotlin 0.1%Language:Objective-C 0.0%