{"id":7388,"date":"2021-08-13T11:34:33","date_gmt":"2021-08-13T11:34:33","guid":{"rendered":"https:\/\/www.getwidget.dev\/blogs\/flutter-shimmer\/"},"modified":"2024-11-21T11:50:12","modified_gmt":"2024-11-21T11:50:12","slug":"flutter-shimmer","status":"publish","type":"post","link":"https:\/\/www.getwidget.dev\/blog\/flutter-shimmer\/","title":{"rendered":"How to Create Custom Flutter Shimmer Animation"},"content":{"rendered":"<p><a href=\"https:\/\/docs.getwidget.dev\/gf-shimmer\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Shimmer<\/strong><\/a> is basically used to add effective <a href=\"https:\/\/www.getwidget.dev\/blog\/flutter-animation-widget\/\" rel=\"noreferrer\">flutter animations<\/a> while the content is loading. This enhances the look of the UI and makes it more responsive. We can use the shimmer animation effect by using the Flutter Shimmer package available for flutter applications.<\/p>\n<p>So, are you ready to make use of this widget package in the Flutter application? It adds styling to your component. This Flutter widget enhances the look of the widgets. If so, then let&#8217;s quickly jump into the usage and the ways a Shimmer can be modified and used to make user-friendly apps. Here I am going to use an open-source UI Library known as GetWidget to build this Shimmer <a href=\"https:\/\/www.getwidget.dev\/blog\/what-is-widget-in-flutter\/\" data-wpil-monitor-id=\"222\">widget in Flutter<\/a>. Inside scaffold, this can be designed, so before creating this we need to create a page with the scaffold.<\/p>\n<h3 id=\"design-custom-flutter-shimmer-with-gfwidget\">Design Custom Flutter Shimmer with GFwidget<\/h3>\n<p><a href=\"https:\/\/docs.getwidget.dev\/gf-shimmer\/\" target=\"_blank\" rel=\"noopener\"><strong>GFShimmer<\/strong><\/a> is a <strong>Flutter Shimmer <\/strong>that adds beautiful animations while the content is loading from the servers. It enhances the look and feels of the content or we can say the widget. We can also use shimmer by giving Linear Gradient for a more visual shimmer effect or just by adding Main Colour and Secondary Color for the basic shimmer effect. It has customization options which is an easy way to handle it as per the application and its requirements.<\/p>\n<h3 id=\"how-to-get-started-with-flutter-shimmer\">How to Get Started with Flutter Shimmer<\/h3>\n<p>Now here is the guide about how we should start developing the <strong>GFShimmer <\/strong>Widget with the use of the <strong>GetWidget<\/strong> UI Library.<\/p>\n<p>First, Let go with<strong> <a href=\"https:\/\/docs.getwidget.dev\/getting-started\/\" target=\"_blank\" rel=\"noopener\"><strong>Getting started<\/strong><\/a><\/strong>, It will guide you on how to start building a beautiful <a href=\"https:\/\/www.ionicfirebaseapp.com\/blogs\/best-flutter-app-examples\/\" target=\"_blank\" rel=\"noopener\">flutter application<\/a> UI with the <strong>GetWidget<\/strong> UI library. Now, we have to install the <strong>GetWidget<\/strong> package from the <strong>pub.dev<\/strong> and use our 1000+ inbuilt Widget. To import the package in your Flutter project follow the below guide.<\/p>\n<blockquote><p><em>Install Package from pub.dev :<\/em><\/p><\/blockquote>\n<p><a href=\"https:\/\/pub.dev\/packages\/getwidget\/\" target=\"_blank\" rel=\"noopener\"><strong>https:\/\/pub.dev\/packages\/getwidget<\/strong><\/a><strong> &#8211; Check the details about GetWidget Package.<\/strong><\/p>\n<h3 id=\"import-full-package\">Import full package:<\/h3>\n<p>import &#8216;package:getwidget\/getwidget.dart&#8217;;<\/p>\n<p><strong>Note: dependencies: getwidget: ^ 4.0.0<\/strong><\/p>\n<blockquote><p><em>Keep playing with the pre-built UI components.<\/em><\/p><\/blockquote>\n<h3 id=\"basic-flutter-shimmer-in-gfwidget\">Basic Flutter Shimmer in GFWidget<\/h3>\n<p><strong>GFShimmer <\/strong>looks like the reflection of a wave or it can also be visualized as a distorted image. The basic <strong>GFShimmer<\/strong> code is given below:<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" class=\"kg-image lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--96-.png\" alt=\"\" width=\"701\" height=\"274\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--96-.png\" alt=\"\" width=\"701\" height=\"274\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">import 'package:getwidget\/getwidget.dart';\n\nGFShimmer(\n  child: shimmerBlock,\n),\n\nfinal Widget shimmerBlock = Padding(\n      padding: const EdgeInsets.symmetric(horizontal: 10),\n      child: Row(\n        crossAxisAlignment: CrossAxisAlignment.start,\n        children: [\n          Container(\n            width: 54,\n            height: 46,\n            color: Colors.white,\n          ),\n          const SizedBox(width: 12),\n          Expanded(\n            child: Column(\n              crossAxisAlignment: CrossAxisAlignment.start,\n              children: [\n                Container(\n                  width: double.infinity,\n                  height: 8,\n                  color: Colors.white,\n                ),\n                const SizedBox(height: 6),\n                Container(\n                  width: MediaQuery.of(context).size.width * 0.5,\n                  height: 8,\n                  color: Colors.white,\n                ),\n                const SizedBox(height: 6),\n                Container(\n                  width: MediaQuery.of(context).size.width * 0.25,\n                  height: 8,\n                  color: Colors.white,\n                ),\n              ],\n            ),\n          )\n        ],\n      ),\n    );\n<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Shimmer with Example Code Snippet<\/span><\/figcaption><\/figure>\n<h3 id=\"flutter-shimmer-with-gradient\">Flutter Shimmer with Gradient<\/h3>\n<p><strong>GFShimmer <\/strong>gives a Shimmer effect for children with Linear Gradient. The most simple way to design it is to use the gradient property in the desired widget.<\/p>\n<p>The example of <strong>GFShimmer<\/strong> Example code is given below:<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" class=\"kg-image lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--97-.png\" alt=\"\" width=\"699\" height=\"95\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--97-.png\" alt=\"\" width=\"699\" height=\"95\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">import 'package:getwidget\/getwidget.dart';\n\nGFShimmer(\n  child: const Text(\n    'GF Shimmer',\n    style: TextStyle(fontSize: 50, fontWeight: FontWeight.w800),\n  ),\n  showGradient: true,\n  gradient: LinearGradient(\n    begin: Alignment.bottomRight,\n    end: Alignment.centerLeft,\n    stops: const [0, 0.2, 0.4, 0.8, 1],\n    colors: [\n     Colors.red,\n     Colors.blue,\n     Colors.green,\n     Colors.orange,\n     Colors.black\n    ],\n  ),\n),\n<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Custom Gradient Shimmer With Example Code Snippet<\/span><\/figcaption><\/figure>\n<h3 id=\"gf-flutter-shimmer-custom-properties\">GF Flutter Shimmer Custom Properties:<\/h3>\n<p>We can change the visualization of GFShimmer by customizing it. The look and feel of <strong>GFShimmer<\/strong> can be customized using the below properties:<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>child<\/strong><\/td>\n<td>The child of type [Widget] to display shimmer effect.<\/td>\n<\/tr>\n<tr>\n<td><strong>duration<\/strong><\/td>\n<td>Controls the speed of the shimmer effect. The default value is 1500 milliseconds.<\/td>\n<\/tr>\n<tr>\n<td><strong>direction<\/strong><\/td>\n<td>Controls the direction of the shimmer effect. The default direction is GFShimmerDirection.leftToRight.<\/td>\n<\/tr>\n<tr>\n<td><strong>gradient<\/strong><\/td>\n<td>Controls the [child]&#8217;s shades of color using Linear gradient. Child [Widget] only takes gradient color, If [showGradient] is true.<\/td>\n<\/tr>\n<tr>\n<td><strong>showShimmerEffect<\/strong><\/td>\n<td>Controls animation effect, defaults true state that makes animation active.<\/td>\n<\/tr>\n<tr>\n<td><strong>showGradient<\/strong><\/td>\n<td>If true, takes gradient color [gradient] for the [child]&#8217;s shimmer effect. Default set to false.<\/td>\n<\/tr>\n<tr>\n<td><strong>shimmerEffectCount<\/strong><\/td>\n<td>Controls the animation shimmerEffectCount. The default value is &#8216;0&#8217;, that displays child [Widget]&#8217;s shimmer effect forever.<\/td>\n<\/tr>\n<tr>\n<td><strong>mainColor<\/strong><\/td>\n<td>Defines the main color of the [child]&#8217;s shimmer effect. Child [Widget] takes the main color, only if [showGradient] is false. Default [showGradient] will be false.<\/td>\n<\/tr>\n<tr>\n<td><strong>secondaryColor<\/strong><\/td>\n<td>Defines the secondary color of the [child]&#8217;s shimmer effect. Child [Widget] takes secondary color, only if [showGradient] is false. Default [showGradient] will be false.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ffffff;color:#ffffff\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ffffff;color:#ffffff\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.getwidget.dev\/blog\/flutter-shimmer\/#can-we-fix-the-direction-of-the-shimmer-effect\" >Can we fix the direction of the shimmer effect?<\/a><\/li><\/ul><\/nav><\/div>\n<h2 id=\"can-we-fix-the-direction-of-the-shimmer-effect\"><span class=\"ez-toc-section\" id=\"can-we-fix-the-direction-of-the-shimmer-effect\"><\/span><strong>Can we fix the direction of the shimmer effect?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Yes, we can add the direction by using the direction property given in the widget. We can use the leftToRight and rightToLeft property respectively.<\/p>\n<h3 id=\"can-we-add-a-timer-for-a-particular-shimmer-effect\">Can we add a timer for a particular shimmer effect?<\/h3>\n<p>Yes, we can add the time duration also by using the duration property. The default duration is 1500 milliseconds.<\/p>\n<h3 id=\"is-there-any-specific-child-widget-that-we-can-use-in-the-shimmer-effect\">Is there any specific child widget that we can use in the shimmer effect?<\/h3>\n<p>No, there isn&#8217;t any specification of the child widgets. We can use all the possible widgets to make the UI look promising.<\/p>\n<h3 id=\"after-adding-the-gradient-property-in-gfshimmer-it-still-not-reflecting-the-color-why\"><strong>After adding the gradient property in GFShimmer it still not reflecting the color, Why?<\/strong><\/h3>\n<p>For reflecting the color gradient in the given widget we need to set the [showGradient] to true because it controls the shades of color using Linear Gradient.<\/p>\n<h3 id=\"what-is-the-use-of-the-maincolor-property\">What is the use of the mainColor property?<\/h3>\n<p>It defines the main color of the shimmer effect. It only displays when<code>[showGradient<\/code>] is <strong>false. The default<\/strong> value of <code>[showGradient<\/code>] is <strong>false. The same<\/strong> goes for the secondaryColor property also.<\/p>\n<p><a href=\"https:\/\/docs.getwidget.dev\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Get Widget Docs<\/strong><\/a><\/p>\n<p><a href=\"https:\/\/forum.getwidget.dev\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Forum<\/strong><\/a>: if any Find any questions let&#8217;s discuss them on Forum.<\/p>\n<p><a href=\"https:\/\/github.com\/ionicfirebaseapp\/getwidget\/\" target=\"_blank\" rel=\"noopener\"><strong>GitHub Repository<\/strong><\/a>: Please do appreciate our work through Github start<\/p>\n<h3 id=\"conclusion\">Conclusion:<\/h3>\n<p>Here we discuss, what <strong>Flutter Shimmer<\/strong> Widget is? And how we can use and implement it into our Flutter app through the <strong>GetWidget<\/strong> <strong>Shimmer<\/strong> component. Here, there are options to customize the <strong>Shimmer.<\/strong><\/p>\n<h3 id=\"about-our-team\"><strong>About Our Team:<\/strong><\/h3>\n<p>We have been working on Flutter since Flutter launched in beta version in 2017. And our team have been putting hundreds and hundreds of hour to experiment and implementation of Flutter. As well as After successfully delivering enterprise and SAAS applications that have been used by more than 500+ businesses around 119+ countries. Now we are in love with Flutter development and we are very passionate about Flutter development. Now it is something we trying to give a small contribution to the <a href=\"https:\/\/www.getwidget.dev\/\" rel=\"noreferrer\">Flutter Dev Community<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"Design Flutter custom shimmer animation widget a step-by-step guide with example code to use in your app.","protected":false},"author":1,"featured_media":5246,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":"","footnotes":""},"categories":[139],"tags":[],"class_list":{"0":"post-7388","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-flutter","8":"cs-entry"},"_links":{"self":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/comments?post=7388"}],"version-history":[{"count":4,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7388\/revisions"}],"predecessor-version":[{"id":8647,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7388\/revisions\/8647"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/media\/5246"}],"wp:attachment":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/media?parent=7388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/categories?post=7388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/tags?post=7388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}