Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "2.5.1",
"flutterSdkVersion": "3.0.1",
"flavors": {}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://opensource.org/licenses/)
[![Open Source](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://opensource.org/)
![Dart Version](https://img.shields.io/static/v1?label=dart&message=2.14.2&color=00579d)
![Flutter Version](https://img.shields.io/static/v1?label=flutter&message=2.5.1&color=42a5f5)
![Dart Version](https://img.shields.io/static/v1?label=dart&message=2.17.1&color=00579d)
![Flutter Version](https://img.shields.io/static/v1?label=flutter&message=3.0.1&color=42a5f5)
![Null Safety](https://img.shields.io/static/v1?label=null-safety&message=done&color=success)

# **4Dev Flutter - Enquetes para Programadores**
Expand Down Expand Up @@ -114,4 +114,4 @@ O objetivo do treinamento é mostrar como criar um aplicativo com Flutter usando
* Test Doubles
* Mocks
* Stubs
* Spies
* Spies
86 changes: 86 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
require_trailing_commas: true
always_put_required_named_parameters_first: true
use_super_parameters: true
always_declare_return_types: true
avoid_print: true
curly_braces_in_flow_control_structures: true
sized_box_shrink_expand: true
avoid_unnecessary_containers: true
avoid_web_libraries_in_flutter: true
no_logic_in_create_state: false
prefer_const_constructors: true
prefer_const_constructors_in_immutables: true
prefer_const_declarations: true
prefer_const_literals_to_create_immutables: true
sized_box_for_whitespace: true
use_full_hex_values_for_flutter_colors: true
cancel_subscriptions: true
close_sinks: true
comment_references: false
one_member_abstracts: false
# only_throw_errors: true
package_api_docs: true
prefer_single_quotes: true
sort_child_properties_last: true
camel_case_types: true
library_names: true
file_names: true
library_prefixes: true
non_constant_identifier_names: true
constant_identifier_names: false
directives_ordering: true
slash_for_doc_comments: false
prefer_interpolation_to_compose_strings: true
prefer_collection_literals: true
avoid_function_literals_in_foreach_calls: false
avoid_init_to_null: true
prefer_initializing_formals: true
type_init_formals: true
empty_constructor_bodies: true
empty_statements: true
unnecessary_new: true
unnecessary_this: true
unnecessary_const: true
unnecessary_overrides: true
unnecessary_parenthesis: true
unnecessary_getters_setters: true
avoid_setters_without_getters: true
avoid_return_types_on_setters: true
parameter_assignments: true
prefer_function_declarations_over_variables: false
unawaited_futures: false
prefer_relative_imports: true
annotate_overrides: false
overridden_fields: false
deprecated_member_use: true


# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
12 changes: 2 additions & 10 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="ForDev"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
Expand All @@ -24,15 +25,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
10 changes: 4 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.21'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6 changes: 3 additions & 3 deletions lib/data/cache/cache.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export './save_secure_cache_storage.dart';
export './fetch_secure_cache_storage.dart';
export './cache_storage.dart';
export './delete_secure_cache_storage.dart';
export './cache_storage.dart';
export './fetch_secure_cache_storage.dart';
export './save_secure_cache_storage.dart';
4 changes: 2 additions & 2 deletions lib/data/cache/cache_storage.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
abstract class CacheStorage {
Future<dynamic> fetch(String key);
Future<void> delete(String key);
Future<void> save({ required String key, required dynamic value });
}
Future<void> save({required String key, required dynamic value});
}
2 changes: 1 addition & 1 deletion lib/data/cache/delete_secure_cache_storage.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
abstract class DeleteSecureCacheStorage {
Future<void> delete(String key);
}
}
2 changes: 1 addition & 1 deletion lib/data/cache/fetch_secure_cache_storage.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
abstract class FetchSecureCacheStorage {
Future<String?> fetch(String key);
}
}
7 changes: 2 additions & 5 deletions lib/data/cache/save_secure_cache_storage.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
abstract class SaveSecureCacheStorage {
Future<void> save({
required String key,
required String value
});
}
Future<void> save({required String key, required String value});
}
4 changes: 4 additions & 0 deletions lib/data/data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export './cache/cache.dart';
export './http/http.dart';
export './models/models.dart';
export './usecases/usecases.dart';
2 changes: 1 addition & 1 deletion lib/data/http/http.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export './http_client.dart';
export './http_error.dart';
export './http_error.dart';
2 changes: 1 addition & 1 deletion lib/data/http/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ abstract class HttpClient {
Map? body,
Map? headers,
});
}
}
2 changes: 1 addition & 1 deletion lib/data/http/http_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ enum HttpError {
unauthorized,
forbidden,
invalidData
}
}
45 changes: 24 additions & 21 deletions lib/data/models/local_survey_answer_model.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../../domain/entities/entities.dart';
import '../../domain/domain.dart';

class LocalSurveyAnswerModel {
final String? image;
Expand All @@ -7,42 +7,45 @@ class LocalSurveyAnswerModel {
final int percent;

LocalSurveyAnswerModel({
this.image,
required this.answer,
required this.isCurrentAnswer,
required this.percent,
this.image,
});

factory LocalSurveyAnswerModel.fromJson(Map json) {
if (!json.keys.toSet().containsAll(['answer', 'isCurrentAnswer', 'percent'])) {
if (!json.keys
.toSet()
.containsAll(<String>['answer', 'isCurrentAnswer', 'percent'])) {
throw Exception();
}
return LocalSurveyAnswerModel(
image: json['image'],
answer: json['answer'],
isCurrentAnswer: json['isCurrentAnswer'].toLowerCase() == 'true',
percent: int.parse(json['percent'])
percent: int.parse(json['percent']),
);
}

factory LocalSurveyAnswerModel.fromEntity(SurveyAnswerEntity entity) => LocalSurveyAnswerModel(
image: entity.image,
answer: entity.answer,
percent: entity.percent,
isCurrentAnswer: entity.isCurrentAnswer
);
factory LocalSurveyAnswerModel.fromEntity(SurveyAnswerEntity entity) =>
LocalSurveyAnswerModel(
image: entity.image,
answer: entity.answer,
percent: entity.percent,
isCurrentAnswer: entity.isCurrentAnswer,
);

SurveyAnswerEntity toEntity() => SurveyAnswerEntity(
image: image,
answer: answer,
isCurrentAnswer: isCurrentAnswer,
percent: percent
);
image: image,
answer: answer,
isCurrentAnswer: isCurrentAnswer,
percent: percent,
);

Map toJson() => {
'image': image,
'answer': answer,
'isCurrentAnswer': isCurrentAnswer.toString(),
'percent': percent.toString()
};
}
'image': image,
'answer': answer,
'isCurrentAnswer': isCurrentAnswer.toString(),
'percent': percent.toString()
};
}
38 changes: 20 additions & 18 deletions lib/data/models/local_survey_model.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../../domain/entities/entities.dart';
import '../../domain/domain.dart';

class LocalSurveyModel {
final String id;
Expand All @@ -14,7 +14,9 @@ class LocalSurveyModel {
});

factory LocalSurveyModel.fromJson(Map json) {
if (!json.keys.toSet().containsAll(['id', 'question', 'date', 'didAnswer'])) {
if (!json.keys
.toSet()
.containsAll(['id', 'question', 'date', 'didAnswer'])) {
throw Exception();
}
return LocalSurveyModel(
Expand All @@ -26,23 +28,23 @@ class LocalSurveyModel {
}

factory LocalSurveyModel.fromEntity(SurveyEntity entity) => LocalSurveyModel(
id: entity.id,
question: entity.question,
date: entity.dateTime,
didAnswer: entity.didAnswer,
);
id: entity.id,
question: entity.question,
date: entity.dateTime,
didAnswer: entity.didAnswer,
);

SurveyEntity toEntity() => SurveyEntity(
id: id,
question: question,
dateTime: date,
didAnswer: didAnswer,
);
id: id,
question: question,
dateTime: date,
didAnswer: didAnswer,
);

Map<String, String> toJson() => {
'id': id,
'question': question,
'date': date.toIso8601String(),
'didAnswer': didAnswer.toString(),
};
}
'id': id,
'question': question,
'date': date.toIso8601String(),
'didAnswer': didAnswer.toString(),
};
}
Loading