Skip to content

Instantly share code, notes, and snippets.

☕️
coding

Felix Angelov felangel

View GitHub Profile
@felangel
felangel / main.dart
Created Apr 11, 2019
[flutter_bloc_recipes] BlocListener
View main.dart
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:meta/meta.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@felangel
felangel / search_form.dart
Last active Apr 9, 2019
[github_search] Flutter Search Form Complete
View search_form.dart
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:common_github_search/common_github_search.dart';
class SearchForm extends StatefulWidget {
final GithubRepository githubRepository;
const SearchForm({
@felangel
felangel / search_form.dart
Last active Apr 9, 2019
[github_search] Flutter Search Form
View search_form.dart
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:common_github_search/common_github_search.dart';
class SearchForm extends StatefulWidget {
final GithubRepository githubRepository;
const SearchForm({
@felangel
felangel / login_form.dart
Last active Apr 8, 2019
[flutter_login] Login Form
View login_form.dart
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_login/authentication/authentication.dart';
import 'package:flutter_login/login/login.dart';
class LoginForm extends StatefulWidget {
final LoginBloc loginBloc;
final AuthenticationBloc authenticationBloc;
@felangel
felangel / main.dart
Created Mar 30, 2019
setState behavior
View main.dart
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
@immutable
abstract class MyState {}
class Uninitialized extends MyState {}
class Loading extends MyState {}
@felangel
felangel / counter_bloc.dart
Last active Mar 25, 2019
[bloc_package] counter bloc w/ onTransition
View counter_bloc.dart
enum CounterEvent { increment, decrement }
class CounterBloc extends Bloc<CounterEvent, int> {
@override
int get initialState => 0;
@override
void onTransition(Transition<CounterEvent, int> transition) {
print(transition);
}
@felangel
felangel / counter_bloc.dart
Last active Mar 25, 2019
[bloc_package] counter bloc
View counter_bloc.dart
enum CounterEvent { increment, decrement }
class CounterBloc extends Bloc<CounterEvent, int> {
@override
int get initialState => 0;
@override
Stream<int> mapEventToState(CounterEvent event) async* {
switch (event) {
case CounterEvent.decrement:
View chat_event.dart
import 'package:equatable/equatable.dart';
import 'package:flutter_app/network/response/message_response.dart';
abstract class ChatEvent extends Equatable {
ChatEvent([List props = const []]) : super(props);
}
class SendMessageEvent extends ChatEvent {
final MessagesResponse newMessage;
View chat_state.dart
import 'package:equatable/equatable.dart';
import 'package:flutter_app/network/response/message_response.dart';
abstract class ChatState extends Equatable {
ChatState([List props = const []]) : super(props);
}
class ChatInitial extends ChatState {
@override
String toString() => 'ChatInitial';
View chat_bloc.dart
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/chat_page/chat.dart';
import 'package:flutter_app/network/request/send_message_request.dart';
import 'package:flutter_app/network/response/message_response.dart';
import 'package:flutter_app/network/response/send_message_response.dart';
import 'package:flutter_app/network/service/base_call_back.dart';
import 'package:flutter_app/network/service/network_factory.dart';
You can’t perform that action at this time.