Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter web app progress indicator before loading app?

Hi I am a mobile app developer and not much familiar with web development, I was finding any approach to implement Progress Indicator before loading the flutter web app like Gmail loading screen. Flutter web is cool but it takes few moments before loading the app. Can we add any indicator for this loading duration? Any code implemented in flutter would be the part of flutter app and it won't work, There should be another approach to achieve this.

like image 223
Shahzad Akram Avatar asked Jul 25 '19 20:07

Shahzad Akram


People also ask

Is it a good idea to build a web app with Flutter?

Flutter is an ideal choice for businesses looking to develop an app for the web and mobile at the same time. With Flutter, a single codebase can be used to develop apps for different platforms. This saves time and reduces headaches typically associated with developing two apps simultaneously.


1 Answers

With the help of @Abhilash, I was able to accomplish this. I got loader code from w3schools.

My project/web/index.html is like this.

<html>

<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script defer src="index.dart.js" type="application/javascript"></script>

  <style>
    .loading {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0;
      position: absolute;
      top: 50%;
      left: 50%;
      -ms-transform: translate(-50%, -50%);
      transform: translate(-50%, -50%);
    }
    
    .loader {
      border: 16px solid #f3f3f3;
      border-radius: 50%;
      border-top: 16px solid blue;
      border-right: 16px solid green;
      border-bottom: 16px solid red;
      border-left: 16px solid pink;
      width: 120px;
      height: 120px;
      -webkit-animation: spin 2s linear infinite;
      animation: spin 2s linear infinite;
    }
    
    @-webkit-keyframes spin {
      0% {
        -webkit-transform: rotate(0deg);
      }
      100% {
        -webkit-transform: rotate(360deg);
      }
    }
    
    @keyframes spin {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }
  </style>
</head>

<body>
  <div class="loading">
    <div class="loader"></div>
  </div>

  <script src="main.dart.js" type="application/javascript"></script>
</body>

</html>
like image 161
Shahzad Akram Avatar answered Sep 20 '22 04:09

Shahzad Akram