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
Last active Jul 10, 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 / gist:4cad77b0165137637d8311b0a3c3a655
Created Jul 9, 2019
[flutter_bloc_0.19.0] MultiRepositoryProvider
View gist:4cad77b0165137637d8311b0a3c3a655
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
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 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 Jun 29, 2019
[flutter_bloc_recipes] Navigation: Routes
View main.dart
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() {
runApp(
BlocProvider(
builder: (context) => MyBloc(),
child: MyApp(),
You can’t perform that action at this time.