<?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 Chamod Weerasinghe on Medium]]></title>
        <description><![CDATA[Stories by Chamod Weerasinghe on Medium]]></description>
        <link>https://medium.com/@chamodweerasinghe8?source=rss-9d818f3d6cc8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1acm6mLlwE-64rVyvCzO_Q.jpeg</url>
            <title>Stories by Chamod Weerasinghe on Medium</title>
            <link>https://medium.com/@chamodweerasinghe8?source=rss-9d818f3d6cc8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:56:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chamodweerasinghe8/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[Flutter — Local Notifications]]></title>
            <link>https://medium.com/@chamodweerasinghe8/flutter-local-notifications-6d4246186c2d?source=rss-9d818f3d6cc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d4246186c2d</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[introduction]]></category>
            <category><![CDATA[permission]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[local-notifications]]></category>
            <dc:creator><![CDATA[Chamod Weerasinghe]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 11:52:50 GMT</pubDate>
            <atom:updated>2025-06-25T11:52:50.282Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Local Notifications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZolg51NxFMu4a71ixAW4g.png" /><figcaption>Local Notification—Image</figcaption></figure><h3>Introduction</h3><p>As a Flutter mobile developer, handling <strong>local notifications</strong> is a mandatory part. This article provides a step-by-step guide to setting up local notifications on both Android and iOS devices.</p><p>Local notifications are trigger from the own device not from any external server.</p><h3>Install dependencies</h3><p><strong>flutter_local_notifications</strong> is most popular plugin for local notifications. <strong>timezone</strong> is need to only scheduled notifications. Some android versions fail to give permission without <strong>permission_handler. </strong>Add all plugins into <strong>pubspec.yaml</strong> file.</p><pre>dependencies:<br>  flutter_local_notifications: ^14.1.1<br>  timezone: ^0.9.0<br>  permission_handler: ^11.3.1</pre><h3>Android Configurations in AndroidManifest.xml</h3><p>After got all the below permissions make your notification process perfect. ( android/app/src/main/AndroidManifest.xml )</p><pre>&lt;uses-permission android:name=&quot;android.permission.POST_NOTIFICATIONS&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.RECEIVE_BOOT_COMPLETED&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.SCHEDULE_EXACT_ALARM&quot; /&gt;</pre><h3>iOS Confgurations in AppDelegate.swift</h3><p>Change the AppDelegate.swift file ( ios/Runner/AppDelegate.swift ) like this.</p><pre>import UIKit<br>import Flutter<br><br>@UIApplicationMain<br>@objc class AppDelegate: FlutterAppDelegate {<br>  override func application(<br>    _ application: UIApplication,<br>    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?<br>  ) -&gt; Bool {<br>    <br>    if #available(iOS 10.0, *) {<br>      UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate<br>    }<br>    <br>    GeneratedPluginRegistrant.register(with: self)<br>    return super.application(application, didFinishLaunchingWithOptions: launchOptions)<br>  }<br>}</pre><h3>Notifications Initialization in main.dart</h3><p>Setup <strong>main.dart </strong>( lib/main.dart ) like this.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_local_notifications/flutter_local_notifications.dart&#39;;<br>import &#39;./pages/homepage.dart&#39;;<br><br>// Create a global instance of the FlutterLocalNotificationsPlugin<br>final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =<br>    FlutterLocalNotificationsPlugin();<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  // Android-specific initialization settings using the app icon<br>  const AndroidInitializationSettings initializationSettingsAndroid =<br>      AndroidInitializationSettings(&#39;@mipmap/ic_launcher&#39;);<br>  // Overall initialization settings<br>  const InitializationSettings initializationSettings = InitializationSettings(<br>    android: initializationSettingsAndroid,<br>  );<br><br>  await flutterLocalNotificationsPlugin.initialize(initializationSettings);<br><br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      title: &#39;Flutter Notification&#39;,<br>      theme: ThemeData(<br>        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),<br>        useMaterial3: true,<br>      ),<br>      home: const Homepage(),<br>    );<br>  }<br>}</pre><h3>Finally, Use local notifications</h3><p>Now you can use local notifications to trigger a function, perform an action, or schedule one by time. In this example, I simply use it to trigger after a button click.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_local_notifications/flutter_local_notifications.dart&#39;;<br>import &#39;../main.dart&#39;;<br><br>class Homepage extends StatefulWidget {<br>  const Homepage({super.key});<br><br>  @override<br>  State&lt;Homepage&gt; createState() =&gt; _HomepageState();<br>}<br><br>class _HomepageState extends State&lt;Homepage&gt; {<br>  void _showNotification() async {<br>    const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(<br>      &#39;channel_id&#39;,<br>      &#39;Basic Notifications&#39;,<br>      channelDescription: &#39;This is a basic notification&#39;,<br>      importance: Importance.max,<br>      priority: Priority.high,<br>    );<br><br>    const NotificationDetails platformDetails =<br>        NotificationDetails(android: androidDetails);<br><br>    await flutterLocalNotificationsPlugin.show(<br>      0,<br>      &#39;Hello!&#39;,<br>      &#39;You clicked the button!&#39;,<br>      platformDetails,<br>    );<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: const Text(&#39;Home Page&#39;),<br>      ),<br>      body: Center(<br>        child: Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            const Text(<br>              &#39;Check Notifications!&#39;,<br>              style: TextStyle(fontSize: 24),<br>            ),<br>            ElevatedButton(<br>              onPressed: _showNotification,<br>              child: const Text(&#39;Click Me to Notify&#39;),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Local notification is a main feature for many Flutter applications, providing a direct communication channel with users even when your app isn’t active. Remember to always respect user preferences, provide clear value with your notifications, and thoroughly test across different devices and operating system versions. There may be some device specific issues.</p><p>In advance, developer can customize the notification sound and icon etc. This is a basic guide and try them after get this base about flutter notifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*ngHlwmxbHFQZmJkfIuNNjg.gif" /></figure><p><a href="https://github.com/chamodlw/flutter_local_notifications.git">GitHub - chamodlw/flutter_local_notifications</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d4246186c2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — State Management with Riverpod]]></title>
            <link>https://medium.com/@chamodweerasinghe8/flutter-state-management-with-riverpod-324dfb154646?source=rss-9d818f3d6cc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/324dfb154646</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[riverpod]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[large-scale-application]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Chamod Weerasinghe]]></dc:creator>
            <pubDate>Mon, 21 Apr 2025 16:54:02 GMT</pubDate>
            <atom:updated>2025-04-21T16:54:02.170Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — State Management with Riverpod</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rn0yCrc-7Vg7Skcy-Rev9w.png" /><figcaption>Flutter-Riverpod</figcaption></figure><h3>1. Introduction</h3><p>Flutter developers use several methods for state management. Developers select the method according to the scale of application.<br><strong>1. Small Applications — setState, InheritedWidget, Providers<br>2. Large Applications — Riverpod, BloC</strong></p><p>In here, continue with <strong>Riverpod. </strong>Simply explain how to use Riverpod.</p><h3>2. Installation &amp; Initialization</h3><p>First, you need to add <strong>flutter_riverpod</strong> dependency to <strong>pubspec.yml </strong>by run<br><strong>flutter pub add flutter_riverpod</strong> command in the terminal.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  flutter_riverpod: ^2.6.1</pre><p>After, you need to initialize Riverpod to the app. <strong>ProviderScope</strong> is the specialized widget; do it in the <strong>main.dart</strong></p><pre>void main() {<br>  runApp(const ProviderScope(child: MyApp()));<br>}</pre><h3>3. Implement Providers File</h3><p>In Riverpod, use several types of providers. There are more types to use for complex state management purposes.<br>Ex: <strong>StateProvider, StateNotifierProvider, ChangeNotifierProvider, FutureProvider, StreamProvider<br></strong>Here is the <strong>counter_provider.dart</strong> file in my sample project. In here I use <strong>StateProvider, </strong>but I explain other provider types also under comments.</p><pre>import &#39;package:flutter_riverpod/flutter_riverpod.dart&#39;;<br><br>final counterProvider = StateProvider&lt;int&gt;((ref) =&gt; 0);</pre><pre>//StateNotifierProvider<br>final stateNotifierCounterProvider =<br>    StateNotifierProvider&lt;CounterNotifier, int&gt;((ref) =&gt; CounterNotifier());<br><br>//ChangeNotifierProvider<br>final changeNotifierCounterProvider =<br>    ChangeNotifierProvider&lt;ChangeNotifierCounter&gt;((ref) =&gt; ChangeNotifierCounter());<br><br>//NotifierProvider<br>final notifierCounterProvider = NotifierProvider&lt;NewCounter, int&gt;(NewCounter.new);<br><br>//FutureProvider<br>final futureCounterProvider = FutureProvider&lt;int&gt;((ref) async {<br>  await Future.delayed(Duration(seconds: 1));<br>  return 42;<br>});</pre><h3>4. read &amp; watch</h3><p>When we use Riverpod, we need to know how to use read and watch in correct positions.<br><strong>read </strong><br>Use to access providers once without listening to their changes. Normally, in button clicks, event handlers, or one-time operations, use this in the Riverpods.</p><pre>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    final countController = ref.read(counterProvider.notifier);<br>    return Scaffold(<br>      appBar: AppBar(title: const Text(&#39;Riverpod Counter&#39;)),<br>      body: const Center(child: CounterCard()),<br>      floatingActionButton: Row(<br>        mainAxisAlignment: MainAxisAlignment.end,<br>        children: [<br>          FloatingActionButton(<br>            heroTag: &#39;decrement&#39;,<br>            onPressed: () {<br>              countController.state--;<br>            },<br>            child: const Icon(Icons.remove),<br>          ),<br>          const SizedBox(width: 10),<br>          FloatingActionButton(<br>            heroTag: &#39;reset&#39;,<br>            onPressed: () =&gt; {<br>              countController.state = 0,<br>            },<br>            child: const Icon(Icons.refresh),<br>          ),<br>          const SizedBox(width: 10),<br>          FloatingActionButton(<br>            heroTag: &#39;increment&#39;,<br>            onPressed: () =&gt; {<br>              countController.state++,<br>            },<br>            child: const Icon(Icons.add),<br>          ),<br>        ],<br>      ),<br>    );<br>  }</pre><p>Here, only when you click the buttons, access (read) the provider’s value.</p><p><strong>watch<br></strong>Use listen to the provider&#39;s values and rebuild according to its changes.<br>Here, the count is continuously listening (watch) to the provider’s value.</p><pre>    final count = ref.watch(counterProvider);</pre><h3>5. Consumer Widget</h3><p>In Riverpod, the Consumer widget is a special type of widget that helps to efficiently rebuild (only the part using the data is rebuilt). Helps keep widgets stateless and reactive.<br>Here, sample consumer widget.</p><pre>import &#39;package:flutter_riverpod/flutter_riverpod.dart&#39;;<br>import &#39;../providers/counter_provider.dart&#39;;<br><br>class CounterCard extends ConsumerWidget {<br>  const CounterCard({super.key});<br><br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    final count = ref.watch(counterProvider);<br><br>    return Card(<br>        //Card UI<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3>6. Sample project (Riverpods use to state management)</h3><p>This is a sample project to get a basic idea of how to implement Riverpod providers for state management in an application. In here, <strong>counterProvider</strong> is a stateprovider type provider that is used with Riverpod.</p><p><a href="https://github.com/chamodlw/riverpods-flutter.git">GitHub - chamodlw/riverpods-flutter</a></p><p>Through this article, the aim is to give guidance to start state management with Riverpod. That is better for complex state management and large-type applications.<br>Riverpods are better than many other state management techniques because they are more powerful but no more complex to implement.<br>Explore your experience with Riverpods.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=324dfb154646" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Curved Navigation Bar]]></title>
            <link>https://medium.com/@chamodweerasinghe8/flutter-curved-navigation-bar-e6687cdefab3?source=rss-9d818f3d6cc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6687cdefab3</guid>
            <category><![CDATA[bottomnavigationbar]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[stylish]]></category>
            <category><![CDATA[easy]]></category>
            <category><![CDATA[customized]]></category>
            <dc:creator><![CDATA[Chamod Weerasinghe]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 19:06:54 GMT</pubDate>
            <atom:updated>2025-03-29T19:06:54.093Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Curved Navigation Bar</h3><figure><img alt="curved bottom navigation" src="https://cdn-images-1.medium.com/max/600/1*fG4qscBj6DS_tR2ZtpoQLw.png" /></figure><h3>Introduction</h3><p>The navigation bar is a main part of the mobile app, providing seamless movement between different screens. We need a more user-friendly UI. The <strong>curved navigation bar</strong> in Flutter allows us to create a modern, animated, and curved bottom navigation experience using the help of a dependency.</p><h3>Install package</h3><p>Run this command in your terminal:</p><pre>flutter pub add curved_navigation_bar</pre><p>Open<strong> </strong>the <strong>pubspec.yml </strong>file to check package installation.</p><pre>dependencies:<br>  curved_navigation_bar: ^1.0.6</pre><h3>Implement navigation bar code</h3><ol><li>Import HomePage() (rename it to your preference) and use it in the <strong>‘main.dart’</strong>.</li></ol><pre>import &#39;package:curved_nav_bar/homepage.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      theme: ThemeData(<br>        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),<br>        useMaterial3: true,<br>      ),<br>      home: const HomePage(),<br>    );<br>  }<br>}</pre><p>2. Implement navigation page codebase (Ex: homepage.dart)</p><pre>import &#39;package:curved_nav_bar/pages/home.dart&#39;;<br>import &#39;package:curved_nav_bar/pages/notification.dart&#39;;<br>import &#39;package:curved_nav_bar/pages/profile.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:curved_navigation_bar/curved_navigation_bar.dart&#39;;<br><br>class HomePage extends StatefulWidget {<br>  const HomePage({super.key});<br><br>  @override<br>  State&lt;HomePage&gt; createState() =&gt; _HomePageState();<br>}<br><br>class _HomePageState extends State&lt;HomePage&gt; {<br>  int _selectedIndex = 0;<br><br>  final List&lt;Widget&gt; _pages = [<br>    const Home(),<br>    const Notifications(),<br>    const Profile(),<br>  ];<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: IndexedStack(<br>        index: _selectedIndex,<br>        children: _pages,<br>      ),<br>      bottomNavigationBar: CurvedNavigationBar(<br>        color: Colors.blue,<br>        //more adjustments<br>        items: const &lt;Widget&gt;[<br>          Icon(Icons.home, size: 30, color: Colors.black),<br>          Icon(Icons.notification_add, size: 30, color: Colors.black),<br>          Icon(Icons.person, size: 30, color: Colors.black),<br>        ],<br>        onTap: (index) {<br>          setState(() {<br>            _selectedIndex = index;<br>          });<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>3. Build navigation pages</p><p>This is one of the sample navigation pages for the notification page.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class Notifications extends StatelessWidget {<br>  const Notifications({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: const Text(&quot;Notifications&quot;)),<br>      body: const Center(child: Text(&quot;Notification Page&quot;)),<br>    );<br>  }<br>}</pre><h3>Add more adjustments to improve bottom bar</h3><p>You can customize the UI of the bottom bar by setting its various properties. The features are available.</p><pre><strong>color</strong>: The color of the navigation bar<br><strong>buttonBackgroundColor</strong>: The background color of buttons<br><strong>backgroundColor</strong>: The color of the navigation bar&#39;s background<br><strong>animationDuration</strong>: Duration for smooth transition<br><strong>height</strong>: Navigation bar height</pre><pre>      bottomNavigationBar: CurvedNavigationBar(<br>        color: Colors.blue,<br>        backgroundColor: Colors.white,<br>        buttonBackgroundColor: Colors.blueGrey,<br>        height: 65.0,<br>        animationDuration: const Duration(milliseconds: 200),<br>        items: const &lt;Widget&gt;[<br>          Icon(Icons.home, size: 30, color: Colors.white),<br>          Icon(Icons.notification_add, size: 30, color: Colors.white),<br>          Icon(Icons.person, size: 30, color: Colors.white),<br>        ],<br>        onTap: (index) {<br>          setState(() {<br>            _selectedIndex = index;<br>          });<br>        },<br>      ),</pre><ul><li><strong>extendBody: true — </strong>Allow the background of the screen to extend behind the curved navigation bar.</li><li><strong>backgroundColor: Colors.transparent — </strong>Remove the default background, making the navbar appear to float over the content.</li></ul><h3>Advantages of this method to bottom navigation</h3><figure><img alt="Advantages" src="https://cdn-images-1.medium.com/max/925/1*hIa1aNwMGjpo610zxQ1k6A.png" /></figure><p>If you want a<strong> </strong>modern, stylish, animated, and smooth<strong> </strong>bottom navigation bar in Flutter, curved_navigation_bar is a great choice!</p><h3>Sample project</h3><p>This project contains 3 basic screen navigations with a curved bottom navigation bar.</p><p><strong>GitHub repository link</strong>: <a href="https://github.com/chamodlw/sample_curved_bottomnav_bar.git">sample_curved_bottomnav_bar</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOvq8QnIEDm-D18s186CAg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6687cdefab3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Shimmer]]></title>
            <link>https://medium.com/@chamodweerasinghe8/flutter-shimmer-684c6f7006f8?source=rss-9d818f3d6cc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/684c6f7006f8</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[userfriendly-app]]></category>
            <category><![CDATA[shimmer]]></category>
            <dc:creator><![CDATA[Chamod Weerasinghe]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 18:30:27 GMT</pubDate>
            <atom:updated>2025-03-03T13:03:48.459Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Shimmer</h3><h3>Introduction</h3><p>A <strong>shimmer</strong> is <strong>an animation to display until loading data</strong>. Applications take time to fetch data. During poor internet connections, it may be a few seconds. Shimmer’s are way to improve user interfaces.</p><p>Commonly used for lists, cards, and images loading to make them friendly to the app users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*l4rqAepmIcMPnaERZrYZag.gif" /><figcaption>shimmer for list view</figcaption></figure><h3>Shimmers Implement in flutter</h3><h4>1. Install Shimmer Package</h4><p>Run the below command, and dependency will appear in the pubspec.yaml file under the dependencies section.</p><pre>flutter pub add shimmer</pre><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  shimmer: ^3.0.0</pre><h4>2. Import the Shimmer Package</h4><p>The import shimmer package to the dart file contains shimmer.</p><pre>import &#39;package:shimmer/shimmer.dart&#39;;</pre><h4>3. First, Create your Screen and apply Shimmer when loading</h4><p>Create the list page and include the data fetch API.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>import &#39;dart:convert&#39;;<br>import &#39;package:shrimmer/components/shrimmer_hompage.dart&#39;; // Corrected import<br><br>class HomePage extends StatefulWidget {<br>  const HomePage({super.key});<br><br>  @override<br>  State&lt;HomePage&gt; createState() =&gt; _HomePageState();<br>}<br><br>class _HomePageState extends State&lt;HomePage&gt; {<br>  List&lt;String&gt; catFacts = [];<br>  bool isLoading = true; // Track loading state<br><br>  @override<br>  void initState() {<br>    super.initState();<br>    fetchCatFacts();<br>  }<br><br>  Future&lt;void&gt; fetchCatFacts() async {<br>    setState(() {<br>      isLoading = true; // Show shimmer before fetching data<br>    });<br><br>    try {<br>      final response = await http.get(Uri.parse(&#39;https://meowfacts.herokuapp.com/?count=5&#39;));<br><br>      if (response.statusCode == 200) {<br>        Map&lt;String, dynamic&gt; data = json.decode(response.body);<br>        setState(() {<br>          catFacts = List&lt;String&gt;.from(data[&#39;data&#39;]).take(5).toList();<br>        });<br>      } else {<br>        throw Exception(&#39;Failed to load cat facts&#39;);<br>      }<br>    } catch (e) {<br>      debugPrint(&#39;Error fetching cat facts: $e&#39;);<br>    } finally {<br>      setState(() {<br>        isLoading = false; // Stop shimmer after fetching data<br>      });<br>    }<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>          //app bar content<br>        ),<br>      body: isLoading<br>          ? const ShimmerWidget() // Show shimmer effect while loading<br>          : ListView.builder(<br>              itemCount: catFacts.length,<br>              itemBuilder: (context, index) {<br>                return Card(<br>                 //card content<br>                );<br>              },<br>            ),<br>    );<br>  }<br>}</pre><h4>4. Shimmer Widget Implement</h4><p>Implement the shimmer widget to use in the list view screen.</p><pre>class ShimmerWidget extends StatelessWidget {<br>  const ShimmerWidget({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Shimmer.fromColors(<br>      baseColor: Colors.grey[300]!,<br>      highlightColor: Colors.grey[100]!,<br>      child: ListView.builder(<br>        itemCount: 5,<br>        itemBuilder: (context, index) {<br>          return Card(<br>            margin: const EdgeInsets.all(10),<br>            child: Padding(<br>              padding: const EdgeInsets.all(15),<br>              child: Row(<br>                children: [<br>                  Container(<br>                    height: 70,<br>                    color: Colors.white,<br>                  ),<br>                ],<br>              ),<br>            ),<br>          );<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>After developing and running the project, shimmer will apply when loading data.</p><h3>Sample Code Base</h3><p>This is a simple Flutter application to fetch “Cat Facts,” and I have used shimmers when loading facts.</p><p><a href="https://github.com/chamodlw/shrimmer.git">GitHub - chamodlw/shrimmer</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*MOoQII3o1QJWDyuZfVXjCQ.gif" /><figcaption>shimmer effect in ‘Cat Facts’ project</figcaption></figure><h3>References</h3><p>The official Dart &amp; Flutter package repository provides all instructions to install and use packages.</p><p><a href="https://pub.dev/packages/shimmer">shimmer | Flutter package</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=684c6f7006f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — AutoRoute]]></title>
            <link>https://medium.com/@chamodweerasinghe8/flutter-autoroute-df86d3800e22?source=rss-9d818f3d6cc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/df86d3800e22</guid>
            <dc:creator><![CDATA[Chamod Weerasinghe]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 13:09:44 GMT</pubDate>
            <atom:updated>2025-02-15T14:26:09.226Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — AutoRoute</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRBCu96m1wkQAjdhuNXe_w.jpeg" /></figure><h3>Ways to Handle Routings</h3><p>In <strong>Flutter,</strong> there are several ways to <strong>handle routings</strong> (navigating between pages).</p><ol><li>Manual Navigation</li></ol><pre>Navigator.push(<br>  context,<br>  MaterialPageRoute(builder: (context) =&gt; HomeScreen()),<br>);</pre><p>2. Named Routes</p><pre>MaterialApp(<br>  initialRoute: &#39;/&#39;,<br>  routes: {<br>    &#39;/&#39;: (context) =&gt; HomeScreen(),<br>  },<br>);</pre><p><strong>3. AutoRoute (Recommended for Large Apps)</strong></p><h3>Importance of AutoRoute</h3><p>AutoRoute reduces manual route handling time. Its better to use when developing large applications. AutoRoute is better than manual routing for nested navigation.</p><h3>Get Started</h3><p>After creating or existing Flutter application, add the below <strong>three</strong> <strong>dependencies</strong> with relevant versions for your platform:</p><pre>dependencies:<br>  auto_route: ^8.3.0<br><br>dev_dependencies:<br>  auto_route_generator: ^8.1.0<br>  build_runner: ^2.4.11</pre><pre>flutter pub add auto_route  <br>flutter pub add auto_route_generator --dev  <br>flutter pub add build_runner --dev</pre><h3>Route Establishment</h3><ol><li>Create a Router class with <em>@AutoRouterConfig()</em> annotation as below:</li></ol><pre>import &#39;package:auto_route/auto_route.dart&#39;;<br>part &#39;app_router.gr.dart&#39;;<br><br>@AutoRouterConfig()<br>class AppRouter extends _$AppRouter {<br>@override<br>  List&lt;AutoRoute&gt; get routes =&gt; [<br>  ];<br>}</pre><p>2. Annotate with <em>@RoutePage() </em>top of every page/class that needs to route:</p><pre>import &#39;package:auto_route/annotations.dart&#39;;<br>import &#39;package:auto_route/auto_route.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:sam1/routes/app_router.gr.dart&#39;;<br><br>@RoutePage()<br>class ScreenA extends StatelessWidget {<br>  const ScreenA({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>    //rest of code<br>    );<br>  }<br>}</pre><p>3. Generate routes of the ‘<em>app_router.gr.dart</em>’ file using one of the below commands:</p><pre>//generate code <br>dart run build_runner build<br><br>//automatically deletes conflicting generated files before rebuilding<br>dart run build_runner build --delete-conflicting-outputs</pre><p>4. Now use routes in the Router class like below. And import the generated file:</p><pre>import &#39;package:auto_route/auto_route.dart&#39;;<br><br>import &#39;app_router.gr.dart&#39;;<br><br>@AutoRouterConfig()<br>class AppRouter extends $AppRouter {<br>@override<br>  List&lt;AutoRoute&gt; get routes =&gt; [<br>    //initial route<br>    AutoRoute(page: RouteA.page , initial: true),<br><br>    AutoRoute(page: RouteB.page),<br>  ];<br>}</pre><p>5. Use routes like this in your code:</p><pre>ElevatedButton(<br>       onPressed: () {<br>         //use auto routes<br>         AutoRouter.of(context).push(const RouteB());<br>       },<br>       child: Text(&#39;Go to Screen B&#39;),<br>    ),</pre><p>6. Final step: Change the entry point like below to create an instance of router class. and call <em>config()</em> method:</p><pre>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  // root of your application.<br>  @override<br>  Widget build(BuildContext context) {<br>    AppRouter appRouter = AppRouter();<br>    return MaterialApp.router(<br>      routerConfig: appRouter.config(),<br>    );<br>  }<br>}</pre><h3>Sample Code to Reference</h3><p><a href="https://github.com/chamodlw/AutoRoute_basic.git">GitHub - chamodlw/AutoRoute_basic</a></p><h3>Demo Video of Above Reference Code</h3><p><a href="https://drive.google.com/file/d/1BySwzVTTcyCY8e6X2DaDCW4jUU5WdIyG/view?usp=drive_link">Auto_Route.webm</a></p><p>Whether you’re building complex multi-screen<strong> </strong>applications, AutoRoute’s flexibility and powerful features make it an excellent choice for modern Flutter development. Start using AutoRoute<strong> </strong>today to optimize your workflow! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df86d3800e22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postman]]></title>
            <link>https://medium.com/@chamodweerasinghe8/postman-65768e82f9b4?source=rss-9d818f3d6cc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/65768e82f9b4</guid>
            <category><![CDATA[i̇t]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[backend-developer]]></category>
            <dc:creator><![CDATA[Chamod Weerasinghe]]></dc:creator>
            <pubDate>Mon, 20 May 2024 17:52:01 GMT</pubDate>
            <atom:updated>2024-05-20T17:52:01.021Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is… &amp; Why…?</h3><blockquote><strong>Postman</strong> is a collaborative platform designed for API development. It streamlines the creation, sharing, testing, and documentation of APIs. With its user-friendly interface and comprehensive toolset, Postman supports every phase of the API lifecycle, from initial development through testing and ongoing monitoring.</blockquote><figure><img alt="Postman_icon" src="https://cdn-images-1.medium.com/max/1024/1*632FJ9l2Kp45OnUxr3qENw.jpeg" /><figcaption>1.1_Icon</figcaption></figure><h3>Key Features of Postman Tool</h3><blockquote>Postman offers a comprehensive suite of features that streamline API development and testing.</blockquote><p><strong>1. Intuitive API Request Building:</strong></p><p>Postman’s interface makes it easy to create requests by letting users choose HTTP methods (GET, POST, PUT, DELETE, etc.), and specify headers, parameters, and request bodies.</p><figure><img alt="get api" src="https://cdn-images-1.medium.com/max/755/1*_7plPVsLj3sd12d2ODVEzQ.png" /><figcaption>1.2_GET method</figcaption></figure><figure><img alt="post api" src="https://cdn-images-1.medium.com/max/713/1*gxbWdR5sDLQtV_AQNpotsw.png" /><figcaption>1.3_POST method</figcaption></figure><figure><img alt="Other methods" src="https://cdn-images-1.medium.com/max/418/1*k58GiK_5BOC3TVA3Rweatw.png" /><figcaption>1.4_Other methods</figcaption></figure><p><strong>2. Environment Variables</strong></p><p>Use variables to manage different environments (development, staging, production) seamlessly, reducing manual effort and errors.</p><p><strong>3. Automated Testing</strong></p><p>Write test scripts in JavaScript to automate the validation of responses. These tests can run with every request, ensuring your API behaves as expected.</p><p><strong>4. Collection Runner</strong></p><p>Execute a series of requests in a collection to automate end-to-end testing. This feature is particularly useful for regression testing.</p><p><strong>5. Shared Workspaces</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HzebivlmtG3Y9gM1MvvUcg.png" /><figcaption>1.5_Shared Workspaces</figcaption></figure><p>Postman allows team collaboration through shared workspaces where team members can collaborate in real-time, share collections, environments, and more.</p><p><strong>6. Version Control Integration</strong></p><p>Integrate with version control systems like Git to manage changes and maintain the history of your API projects.</p><p><strong>7. Auto-Generated Documentation</strong></p><p>Generate and share API documentation effortlessly. Postman can automatically create documentation from your collections, making it easy to keep your docs up to date.</p><p><strong>8. API Network</strong></p><p>Share your APIs publicly or within your organization through Postman’s API network, promoting reuse and standardization.</p><p><strong>9. Mock Servers</strong></p><p>Create mock servers to simulate your API endpoints before the actual implementation. This helps in parallel development and testing.</p><p><strong>10. Automated Monitoring</strong></p><p>Set up monitors to run your collections at scheduled intervals. Get notified of performance issues or downtime before your users do.</p><h3>Getting Started with Postman</h3><blockquote>Here’s a step-by-step guide to help you get started:</blockquote><p><strong>Step 1: Install Postman</strong></p><p>Download and install Postman from the official <a href="https://www.postman.com/downloads/">website</a>.</p><p><strong>Step 2: Create a New Request</strong></p><p><strong>Step 3: Send the Request</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9hSy9CyvFamd13tey4LbyA.png" /><figcaption>1.6_new URL type here and send</figcaption></figure><p><strong>Step 4: Write Tests</strong></p><p><strong>Step 5: Create a Collection</strong></p><p><strong>Step 6: Use Environment Variables</strong></p><p><strong>Step 7: Run Collections</strong></p><blockquote>By following these steps, you’ll be well on your way to mastering Postman and making your API development and testing processes more efficient and effective.</blockquote><blockquote>Connect Postman with CI/CD tools like <a href="https://www.jenkins.io/download/">Jenkins</a> to automate your testing pipeline.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gzXL-5IX1iUyn-IzOmipZQ.png" /><figcaption>1.7_Screenshot of Interface</figcaption></figure><p>Postman is a vital tool for backend developers, offering a wide array of features for API development and testing. Its user-friendly interface, powerful testing capabilities, and collaborative functions make it an indispensable addition to any developer’s toolkit. By mastering Postman, you can optimize your API workflows, improve teamwork, and ensure your APIs are dependable and well-documented.</p><p>Whether you’re an experienced developer or new to API development, Postman is the tool you need to simplify and enhance your backend testing efforts. Try it out and experience the positive impact it can have on your development process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTAPziW2LqSni98qetPdmA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65768e82f9b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>