title: The state of flutter bloc is not updating if called outside the bloc builder
body: <p>I initialised all necessary blocs in my main file. Even after this, the state of bloc is not updating if called from outside the bloc builder.</p>
  <p>I am trying to implement lazy loading using bloc pattern.</p>
  <p>Supposed action is when listview reaches end scroll listener calls a bloc function which will fetch the next items and pass the latest item along with previous items to ProductsLoadedState();</p>
  <p>But, ProductsLoadedState is not getting trigged even after emitting the state from bloc.</p>
  <p>Any help is really appreciated.
  Thank you.</p>
  <p>My bloc code is :</p>
  <pre><code>void _onLoadProducts(
        LoadProductsPage event, Emitter&lt;ProductsPageState&gt; emit) async {
      print(&quot;getting products&quot;);
      page == 1
          ? emit(const ProductsPageLoadingState(isFirstFetch: true))
          : emit(ProductsPageLoadingState(
              oldProducts: this.products, isFirstFetch: false));
      final List&lt;ProductModel&gt; products =
          await productsRepository.handleGetSearchedProducts(
              event.title,
              event.category,
              event.brand,
              event.condition,
              event.productCode,
              page);
      page++;
      print(&quot;page number $page&quot;);
      this.products.addAll(products);
      print(this.products.length);
      emit(ProductsPageLoadedState(searchedProducts: this.products));
    }
  </code></pre>
  <p>Main.dart file :</p>
  <pre><code>  final AppRouter _appRouter = AppRouter();
  
    MyApp({Key key}) : super(key: key);
    @override
    Widget build(BuildContext context) {
      return MultiBlocProvider(
          providers: [
            BlocProvider&lt;ProductsPageBloc&gt;(
              create: (context) =&gt; ProductsPageBloc(),
            ),
          ],
          child: MultiRepositoryProvider(
            providers: [
              RepositoryProvider(create: (context) =&gt; ProductsRepository()),
              RepositoryProvider(create: (context) =&gt; AuthRepository()),
              RepositoryProvider(create: (context) =&gt; BrandRepository()),
            ],
            child: MaterialApp(
              title: 'title',
              theme: ThemeData(
                  primarySwatch: Colors.blue,
                  fontFamily: 'T MS',
                  scaffoldBackgroundColor: const Color(0xffF6F6F9)),
              onGenerateRoute: _appRouter.onGenerateRoute,
  
              // home : AddressesPage(),
              home: BlocProvider(
                create: (context) =&gt; NetworkBloc(),
                child: BlocBuilder&lt;NetworkBloc, NetworkState&gt;(
                  builder: (context, state) {
                    return UserMain();
                  },
                ),
              ),
            ),
          ));
    }
  }
  </code></pre>
  <p>Products.dart file :</p>
  <pre><code>class ProductsPage extends StatefulWidget {
    final String title;
    final String category;
    final String brand;
    final String condition;
    final int pageNumber;
    final String productCode;
  
    const ProductsPage(
        {Key key,
        this.title,
        this.category,
        this.brand,
        this.condition,
        this.pageNumber,
        this.productCode})
        : super(key: key);
  
    @override
    _ProductsPageState createState() =&gt; _ProductsPageState();
  }
  
  class _ProductsPageState extends State&lt;ProductsPage&gt; {
    String appBarTitle;
    List&lt;ProductModel&gt; products = [];
    bool isLoading = false;
  
    final scrollController = ScrollController();
  
    void setupScrollController(context) {
      scrollController.addListener(() {
        if (scrollController.position.atEdge) {
          if (scrollController.position.pixels != 0) {
            BlocProvider.of&lt;ProductsPageBloc&gt;(context).add(LoadProductsPage(
                title: widget.title,
                category: widget.category,
                brand: widget.brand,
                condition: widget.condition,
                pageNumber: widget.pageNumber,
                productCode: widget.productCode));
          }
        }
      });
    }
  
    @override
    void initState() {
      setupScrollController(context);
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: PreferredSize(
          preferredSize: const Size.fromHeight(50),
          child: CustomAppBar(
            isSearchPage: true,
            title: &quot;tilte&quot;,
            enableSearchBar: true,
          ),
        ),RepositoryProvider.of&lt;ProductsRepository&gt;(context)
        body: BlocProvider(
          create: (context) =&gt; ProductsPageBloc()
            ..add(
              LoadProductsPage(
                  title: widget.title,
                  category: widget.category,
                  brand: widget.brand,
                  condition: widget.condition,
                  pageNumber: widget.pageNumber,
                  productCode: widget.productCode),
            ),
          child: Scaffold(body: Center(
            child: BlocBuilder&lt;ProductsPageBloc, ProductsPageState&gt;(
              builder: (context, state) {
                if (state is ProductsPageLoadingState) {
                  if (state.isFirstFetch) {
                    print(&quot;is first fetch&quot;);
                    return const LoadingSpinnerWidget();
                  } else {
                    print(&quot;is not first fetch${state.oldProducts}&quot;);
                    products = state.oldProducts;
                  }
                } else if (state is ProductsPageLoadedState) {
                  isLoading = false;
                  print(&quot;is loaded ${state.searchedProducts} $isLoading&quot;);
                  products = state.searchedProducts;
                  print(&quot;state${state.searchedProducts.length}&quot;);
                  print(&quot;products${products.length}&quot;);
                }
                if (products.isNotEmpty) {
                  return ListView.builder(
                      controller: scrollController,
                      itemCount: products.length + (isLoading ? 1 : 0),
                      itemBuilder: (context, index) {
                        if (index &lt; products.length) {
                          return ProductHorizontal(product: products[index]);
                        } else {
                          Timer(const Duration(milliseconds: 30), () {
                            scrollController.jumpTo(
                                scrollController.position.maxScrollExtent);
                          });
                          return const LoadingSpinnerWidget();
                        }
                      });
                } else {
                  return const ShowCustomPage(
                    icon: CupertinoIcons.bag,
                    title:
                        &quot;Sorry, we couldn't find any similar products. Please try searching for other products&quot;,
                  );
                }
              },
            ),
          )),
        ),
      );
    }
  }
  </code></pre>