tbib_bloc_extensions

Creator: coderz1093

Last updated:

0 purchases

tbib_bloc_extensions Image
tbib_bloc_extensions Images

Languages

Categories

Add to Cart

Description:

tbib bloc extensions

TBIB_Bloc_Extensions #
Use this extension to get your bloc and access it without context
note v1.0.2 solve can't get bloc if bloc in runApp see how init package #
// 1- need to create navigation key
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

// 2 in material app or cupertino app
MitXMaterialApp(
navigatorKey: navigatorKey,
....
builder: (context, child) {
TBIBBlocExt.init(navigatorKey);
....
return child!
}
);
copied to clipboard
Usage #
// Don't use BlocProvider() but use BlocProviderContext
BlocProviderContext(
create: (context) => YourBloc(),
child: child
);

copied to clipboard

When need to get your bloc

// don't use BlocProvider.of<YourBloc>(context) use
BlocExt.getBloc<YourBloc>();

copied to clipboard
Come see how library work #

// widget BlocProviderContext
@override
Widget build(BuildContext context) {
return BlocProvider(
create: create,
child: Builder(builder: (context) {
BlocExt.setBlocContext = context; // see i get your context and send it to static variable
return child;
}),
);
}

BlocExt.getBloc<YourBloc>() // it use BlocProvider.of<T>(_blocContext)

copied to clipboard

Thank You.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.