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 / weather_bloc.dart
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] WeatherBloc
View weather_bloc.dart
class WeatherBloc extends HydratedBloc<WeatherEvent, WeatherState> {
final WeatherRepository weatherRepository;
WeatherBloc({@required this.weatherRepository})
: assert(weatherRepository != null);
@override
WeatherState get initialState => super.initialState ?? WeatherEmpty();
@override
@felangel
felangel / theme_bloc.dart
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] ThemeBloc
View theme_bloc.dart
class ThemeBloc extends HydratedBloc<ThemeEvent, ThemeState> {
@override
ThemeState get initialState =>
super.initialState ??
ThemeState(
theme: ThemeData.light(),
color: Colors.lightBlue,
);
@override
@felangel
felangel / settings_bloc.dart
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] SettingsBloc
View settings_bloc.dart
class SettingsBloc extends HydratedBloc<SettingsEvent, SettingsState> {
@override
SettingsState get initialState =>
super.initialState ??
SettingsState(temperatureUnits: TemperatureUnits.celsius);
@override
Stream<SettingsState> mapEventToState(SettingsEvent event) async* {
if (event is TemperatureUnitsToggled) {
yield SettingsState(
@felangel
felangel / main.dart
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] Simple HydratedBlocDelegate initialization
View main.dart
import 'package:bloc/bloc.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
void main() async {
BlocSupervisor.delegate = await HydratedBlocDelegate.build();
...
}
@felangel
felangel / main.dart
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] Setting SimpleBlocDelegate
View main.dart
import 'package:bloc/bloc.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
void main() async {
BlocSupervisor.delegate = SimpleBlocDelegate(
await HydratedBlocStorage.getInstance(),
);
...
}
@felangel
felangel / main.dart
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] HydratedBlocDelegate
View main.dart
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
class SimpleBlocDelegate extends HydratedBlocDelegate {
SimpleBlocDelegate(HydratedStorage storage) : super(storage);
@override
void onEvent(Bloc bloc, Object event) {
super.onEvent(bloc, event);
@felangel
felangel / pubspec.yaml
Created Jun 18, 2019
[flutter_bloc_hydrated_weather] pubspec.yaml
View pubspec.yaml
name: flutter_weather
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
flutter:
@felangel
felangel / main.dart
Last active Jul 23, 2019
Recipe: Bloc Access (Global)
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 Aug 29, 2019
Recipe: Bloc Access (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 Jul 23, 2019
Recipe: Bloc Access (Local)
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);
}
You can’t perform that action at this time.