<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rakesh Chandrapal on Medium]]></title>
        <description><![CDATA[Stories by Rakesh Chandrapal on Medium]]></description>
        <link>https://medium.com/@rakesh202078?source=rss-6c5c9817a5d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oYHN8wFqY55Oco7f</url>
            <title>Stories by Rakesh Chandrapal on Medium</title>
            <link>https://medium.com/@rakesh202078?source=rss-6c5c9817a5d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:27:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rakesh202078/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pagination Was Slowing Me Down, So I Built a Flutter Package]]></title>
            <link>https://medium.com/@rakesh202078/pagination-was-slowing-me-down-so-i-built-a-flutter-package-0b807a687f01?source=rss-6c5c9817a5d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b807a687f01</guid>
            <category><![CDATA[flutter-bloc]]></category>
            <category><![CDATA[flutter-bloc-pattern]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <dc:creator><![CDATA[Rakesh Chandrapal]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 07:08:44 GMT</pubDate>
            <atom:updated>2026-01-21T07:08:44.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k933J_M4C3Z6HReNkeRiWw.png" /></figure><h4>I Built a Flutter Pagination Package So I’d Never Have to Write Pagination Again</h4><p>Pagination is one of those problems every Flutter app has — and somehow we all keep re-implementing it.</p><p>Different screens. Different layouts. Same logic.<br>Loading states, errors, empty states, thresholds, pull-to-refresh… over and over again.</p><p>After doing this enough times, I decided to stop repeating myself and built <a href="https://pub.dev/packages/paginated_bloc_widget"><strong>paginated_bloc_widget</strong></a> — a production-ready pagination solution using BLoC that I now use across my apps.</p><h3>Why I Built (and Use) paginated_bloc_widget</h3><p>I didn’t want:</p><ul><li>Scroll listeners in every screen</li><li>Custom pagination logic per layout</li><li>Different loading and error widgets everywhere</li><li>Pagination behavior behaving slightly differently each time</li></ul><p>I wanted:</p><ul><li>One mental model</li><li>One BLoC</li><li>One widget</li><li>Works everywhere</li></ul><p>So I built a package where <strong>pagination is solved once</strong>, and everything else becomes configuration.</p><h3>How It Works (At a High Level)</h3><p>The idea is simple:</p><ol><li><strong>You fetch pages</strong></li><li><strong>The BLoC manages state</strong></li><li><strong>The widget renders any layout you want</strong></li></ol><h3>You only implement one thing: the repository</h3><pre>class UserRepository extends PaginatedDataRepository&lt;User&gt; {<br>  @override<br>  Future&lt;PaginatedResponse&lt;User&gt;&gt; fetchData({<br>    required int page,<br>    int? limit,<br>    Map&lt;String, dynamic&gt;? filters,<br>  }) async {<br>    // fetch data and return PaginatedResponse<br>  }<br>}</pre><p>No UI logic.<br>No scroll math.<br>No state juggling.</p><h3>Plug it into the BLoC</h3><pre>BlocProvider(<br>  create: (_) =&gt; PaginatedDataBloc&lt;User&gt;(<br>    repository: UserRepository(),<br>  )..add(const LoadFirstPage()),<br>  child: ...<br>)</pre><p>That’s it. Pagination is now automatic.</p><h3>Use the Same Widget for Any Layout</h3><p>This is where the package really shines.</p><p>The <strong>same widget</strong> supports:</p><ul><li>ListView</li><li>GridView</li><li>PageView</li><li>Slivers / CustomScrollView</li></ul><pre>PaginatedDataWidget&lt;User&gt;(<br>  layoutType: PaginatedLayoutType.listView,<br>  itemBuilder: (context, user, index) {<br>    return ListTile(title: Text(user.name));<br>  },<br>)</pre><p>Change one enum → completely different UI.<br>No duplicated logic. No rewrites.</p><h3>Global Pagination Configuration (Set Once, Forget Forever)</h3><p>Another pain point I wanted to eliminate was <strong>hardcoded pagination values everywhere</strong>.</p><p>So the package includes a <strong>global config</strong>:</p><pre>void main() {<br>  PaginationConfig.init(<br>    itemsPerPage: 20,<br>    loadMoreThreshold: 0.85,<br>    pageViewLoadMoreOffset: 2,<br>  );<br>  runApp(const MyApp());<br>}</pre><p>This lets you define:</p><ul><li>Default page size</li><li>When “load more” triggers</li><li>PageView prefetch behavior</li></ul><p>Once configured, <strong>every paginated screen follows the same rules unless you override them with local config</strong>.</p><h3>Global &amp; Local Customization (No More Repeated Widgets)</h3><p>Loading, empty, and error states are another place where apps get messy fast.</p><p>This package lets you customize them <strong>globally</strong> or <strong>locally</strong>.</p><h3>Global theming (app-wide consistency)</h3><pre>PaginationTheme(<br>  data: PaginationThemeData(<br>    firstPageLoadingBuilder: (_) =&gt; const CircularProgressIndicator(),<br>    emptyBuilder: (_) =&gt; const Text(&#39;Nothing here&#39;),<br>  ),<br>  child: MyApp(),<br>);</pre><p>Define it once → all pagination widgets use it.</p><h3>Local overrides (when a screen needs something special)</h3><pre>PaginatedDataWidget&lt;User&gt;(<br>  firstPageLoadingWidget: const CustomLoader(),<br>  emptyWidget: const CustomEmptyState(),<br>  firstPageErrorWidget: (error, retry) =&gt; ErrorView(<br>    message: error,<br>    onRetry: retry,<br>  ),<br>  itemBuilder: (context, user, index) =&gt; UserTile(user),<br>);</pre><p>Local overrides always win — no hacks required.</p><h3>The Real Win: Time Saved</h3><p>Before this package:</p><ul><li>Writing pagination logic per feature</li><li>Duplicating BLoC code</li><li>Debugging edge cases</li><li>Rebuilding loaders and error UIs</li></ul><p>After this package:</p><ul><li>One repository</li><li>One BLoC</li><li>One widget</li><li>Infinite layouts</li></ul><p>I’ve easily saved <strong>hours per screen</strong>, and more importantly:</p><ul><li>My codebase is smaller</li><li>Pagination behavior is consistent</li><li>Adding new paginated screens is trivial</li></ul><h3>Final Thoughts</h3><p>I built paginated_bloc_widget to solve a problem I kept hitting myself.</p><p>If you’re using <strong>Flutter + BLoC</strong> and your app has more than one paginated screen, this package lets you stop thinking about pagination entirely — and that’s exactly how it should be.</p><p>Sometimes the best feature<br>is the one you never have to touch again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b807a687f01" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>