Skip to content

Instantly share code, notes, and snippets.

☕️
coding

Felix Angelov felangel

☕️
coding
Block or report user

Report or block felangel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@felangel
felangel / main.dart
Created Aug 4, 2019
[flutter_firestore_todos] main
View main.dart
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_firestore_todos/blocs/authentication_bloc/bloc.dart';
import 'package:todos_repository/todos_repository.dart';
import 'package:flutter_firestore_todos/blocs/blocs.dart';
import 'package:flutter_firestore_todos/screens/screens.dart';
import 'package:user_repository/user_repository.dart';
void main() {
@felangel
felangel / todos_bloc.dart
Created Aug 4, 2019
[flutter_firestore_todos] todos bloc snippet II
View todos_bloc.dart
Stream<TodosState> _mapTodosUpdateToState(TodosUpdated event) async* {
yield TodosLoaded(event.todos);
}
@felangel
felangel / todos_bloc.dart
Created Aug 4, 2019
[flutter_firestore_todos] todos bloc snippet
View todos_bloc.dart
Stream<TodosState> _mapLoadTodosToState() async* {
_todosSubscription?.cancel();
_todosSubscription = _todosRepository.todos().listen(
(todos) {
dispatch(
TodosUpdated(todos),
);
},
);
}
@felangel
felangel / todos_bloc.dart
Created Aug 4, 2019
[flutter_firestore_todos] todos bloc
View todos_bloc.dart
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import 'package:flutter_firestore_todos/blocs/todos/todos.dart';
import 'package:todos_repository/todos_repository.dart';
class TodosBloc extends Bloc<TodosEvent, TodosState> {
final TodosRepository _todosRepository;
StreamSubscription _todosSubscription;
@felangel
felangel / authentication_bloc.dart
Created Aug 4, 2019
[flutter_firestore_todos] authentication bloc
View authentication_bloc.dart
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import 'package:user_repository/user_repository.dart';
import 'package:flutter_firestore_todos/blocs/authentication_bloc/bloc.dart';
class AuthenticationBloc
extends Bloc<AuthenticationEvent, AuthenticationState> {
final UserRepository _userRepository;
@felangel
felangel / authentication_state.dart
Created Aug 4, 2019
[flutter_firestore_todos] authentication states
View authentication_state.dart
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@immutable
abstract class AuthenticationState extends Equatable {
AuthenticationState([List props = const []]) : super(props);
}
class Uninitialized extends AuthenticationState {
@override
@felangel
felangel / authentication_event.dart
Created Aug 4, 2019
[flutter_firestore_todos] authentication events
View authentication_event.dart
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@immutable
abstract class AuthenticationEvent extends Equatable {
AuthenticationEvent([List props = const []]) : super(props);
}
class AppStarted extends AuthenticationEvent {
@override
@felangel
felangel / pubspec.yaml
Created Aug 4, 2019
[flutter_firestore_todos] flutter app pubspec
View pubspec.yaml
name: flutter_firestore_todos
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
@felangel
felangel / firebase_user_repository.dart
Created Aug 4, 2019
[flutter_firestore_todos] firebase user repository
View firebase_user_repository.dart
import 'package:firebase_auth/firebase_auth.dart';
import 'package:user_repository/user_repository.dart';
class FirebaseUserRepository implements UserRepository {
final FirebaseAuth _firebaseAuth;
FirebaseUserRepository({FirebaseAuth firebaseAuth})
: _firebaseAuth = firebaseAuth ?? FirebaseAuth.instance;
Future<bool> isAuthenticated() async {
@felangel
felangel / user_repository.dart
Created Aug 4, 2019
[flutter_firestore_todos] user repository base
View user_repository.dart
abstract class UserRepository {
Future<bool> isAuthenticated();
Future<void> authenticate();
Future<String> getUserId();
}
You can’t perform that action at this time.