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 Feb 28, 2020
Recipe: Bloc Access (Generated Routes)
View main.dart
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class SimpleBlocDelegate extends BlocDelegate {
@override
void onEvent(Bloc bloc, Object event) {
super.onEvent(bloc, event);
print(event);
}
@felangel
felangel / main.dart
Last active Feb 28, 2020
Recipe: Bloc Access (Named Routes)
View main.dart
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class SimpleBlocDelegate extends BlocDelegate {
@override
void onEvent(Bloc bloc, Object event) {
super.onEvent(bloc, event);
print(event);
}
@felangel
felangel / main.dart
Last active Feb 15, 2020
CombinedBloc + combineLatest
View main.dart
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
import 'package:rxdart/rxdart.dart';
enum CounterEvent { increment }
class CounterBloc extends Bloc<CounterEvent, int> {
@felangel
felangel / main.dart
Created Feb 14, 2020
bloc + combineLatest
View main.dart
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:rxdart/rxdart.dart';
enum CounterEvent { increment }
class CounterBloc extends Bloc<CounterEvent, int> {
@override
int get initialState => 0;
View game_bloc.dart
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_cards/models/models.dart';
part 'game_event.dart';
part 'game_state.dart';
@felangel
felangel / main.dart
Created Dec 13, 2019
[flutter_bloc] Location Stream Example
View main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:meta/meta.dart';
import 'package:geolocator/geolocator.dart';
void main() => runApp(MyApp());
@felangel
felangel / main.dart
Created Nov 14, 2019
Equatable HashCode Sample
View main.dart
import './point1.dart' as point1;
import './point2.dart' as point2;
void main() {
final p1 = point1.Point();
final p2 = point2.Point();
print(p1 == p2); // false
print(p1.hashCode == p2.hashCode); // false
}
@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),
);
},
);
}
You can’t perform that action at this time.