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 Jul 9, 2019
[flutter_bloc_0.19.0] MultiRepositoryProvider
View main.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiRepositoryProvider(
providers: [
RepositoryProvider<RepositoryA>(
builder: (context) => RepositoryA(),
),
RepositoryProvider<RepositoryB>(
builder: (context) => RepositoryB(),
@felangel
felangel / main.dart
Created Jul 9, 2019
[flutter_bloc_0.19.0] Nested RepositoryProvider
View main.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RepositoryProvider<RepositoryA>(
builder: (context) => RepositoryA(),
child: RepositoryProvider<RepositoryB>(
builder: (context) => RepositoryB(),
child: RepositoryProvider<RepositoryC>(
builder: (context) => RepositoryC(),
child: ChildA(),
@felangel
felangel / main.dart
Created Jul 9, 2019
[flutter_bloc_0.19.0] MultiBlocProvider
View main.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider<BlocA>(
builder: (BuildContext context) => BlocA(),
),
BlocProvider<BlocB>(
builder: (BuildContext context) => BlocB(),
@felangel
felangel / main.dart
Created Jul 9, 2019
[flutter_bloc_0.19.0] Nested BlocProviders
View main.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider<BlocA>(
builder: (BuildContext context) => BlocA(),
child: BlocProvider<BlocB>(
builder: (BuildContext context) => BlocB(),
child: BlocProvider<BlocC>(
builder: (BuildContext context) => BlocC(),
child: ChildA(),
@felangel
felangel / main.dart
Created Jul 9, 2019
[flutter_bloc_0.19.0] Repository Provider default constructor
View main.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RepositoryProvider(
builder: (context) => MyRepository(),
child: MyChild(),
);
}
}
@felangel
felangel / main.dart
Created Jul 9, 2019
[flutter_bloc_0.19.0] BlocProvider value constructor
View main.dart
Navigator.of(context).push(
MaterialPageRoute<MyPage>(
builder: (context) {
return BlocProvider.value(
value: BlocProvider.of<MyBloc>(context),
child: MyPage(),
);
},
),
);
@felangel
felangel / main.dart
Created Jul 9, 2019
[flutter_bloc_0.19.0] Old BlocProvider
View main.dart
class MyWidget extends StatefulWidget {
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
MyBloc _myBloc;
@override
void initState() {
super.initState();
@felangel
felangel / main.dart
Last active Jul 9, 2019
[flutter_bloc_0.19.0] BlocProvider Default Constructor
View main.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
builder: (BuildContext context) => MyBloc(),
child: MyChild(),
);
}
}
@felangel
felangel / main.dart
Created Jun 26, 2019
Flutter Bloc Stepper
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:equatable/equatable.dart';
abstract class StepperEvent extends Equatable {
StepperEvent([List props = const []]) : super(props);
}
@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
You can’t perform that action at this time.