Skip to content

Commit

Permalink
Merge pull request #13 from alper-efe-sahin/12-injectable-linting
Browse files Browse the repository at this point in the history
Flutter Firebase & DDD Course [7] done
  • Loading branch information
FlutterWiz authored Oct 21, 2022
2 parents 347cb5b + b872163 commit 58165d3
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 17 deletions.
31 changes: 15 additions & 16 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@

# 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
include: package:lint/analysis_options.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:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
always_declare_return_types: true

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
analyzer:
exclude:
- "**/*.freezed.dart"
- "**/*.config.dart"
- "**/*.g.dart"

strong-mode:
implicit-casts: true

errors:
missing_required_param: error
must_be_immutable: error
always_declare_return_types: warning
2 changes: 2 additions & 0 deletions lib/application/auth/sign_in_form/sign_in_form_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import 'package:flutter_firebase_ddd_bloc/domain/auth/i_auth_facade.dart';
import 'package:flutter_firebase_ddd_bloc/domain/auth/value_objects.dart';
import 'package:fpdart/fpdart.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';

part 'sign_in_form_event.dart';
part 'sign_in_form_bloc.freezed.dart';

@injectable
class SignInFormBloc extends Bloc<SignInFormEvent, SignInFormState> {
SignInFormBloc(this._authFacade) : super(SignInFormState.initial()) {
on<SignInWithEmailAndPassword>(
Expand Down
12 changes: 12 additions & 0 deletions lib/domain/core/firebase_injectable.module.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:injectable/injectable.dart';

@module
abstract class FirebaseInjectableModule {
@lazySingleton
GoogleSignIn get googleSignIn => GoogleSignIn();

@lazySingleton
FirebaseAuth get firebaseAuth => FirebaseAuth.instance;
}
2 changes: 2 additions & 0 deletions lib/infrastructure/auth/firebase_auth_facade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import 'package:flutter_firebase_ddd_bloc/domain/auth/value_objects.dart';

import 'package:fpdart/fpdart.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:injectable/injectable.dart';

@LazySingleton(as: IAuthFacade)
class FirebaseAuthFacade implements IAuthFacade {
FirebaseAuthFacade(this._firebaseAuth, this._googleSignIn);

Expand Down
45 changes: 45 additions & 0 deletions lib/injection.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/injection.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter_firebase_ddd_bloc/injection.config.dart';
import 'package:get_it/get_it.dart';
import 'package:injectable/injectable.dart';

final getIt = GetIt.instance;

@injectableInit
void configureInjection(String env) {
$initGetIt(getIt, environment: env);
}
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_firebase_ddd_bloc/firebase_options.dart';
import 'package:flutter_firebase_ddd_bloc/injection.dart';
import 'package:injectable/injectable.dart';

void main() async {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
configureInjection(Environment.prod);
runApp(const AppWidget());
}

Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ dependencies:
flutter_bloc: ^8.1.1
google_sign_in: ^5.4.2
firebase_auth: ^4.0.1
rename: ^2.0.1
injectable: ^1.5.3
get_it: ^7.2.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
Expand All @@ -47,11 +48,13 @@ dev_dependencies:
sdk: flutter
freezed: ^2.2.0
build_runner: ^2.3.0
injectable_generator: ^1.5.4
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
lint: ^1.10.0
flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
Expand Down

0 comments on commit 58165d3

Please sign in to comment.