改编摘自:https://stackoverflow.com/questions/57209754/flutter-web-app-progress-indicator-before-loading-app
Flutter Web 应用导出后,实际打开前面白色的页面特别影响用户留存,于是搜索了一下相关解决方法,给导出的项目加上一个 Loader
在 <head> 标签中添加样式表
<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 #f2be55;
border-right: 16px solid #f28455;
border-bottom: 16px solid #ff5757;
border-left: 16px solid #c93b38;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
/* set background to dark */
body {
background-color: #1a1a1a;
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
在 <body> 中, Flutter 的运行代码前添加加载动画
<body>
<div class="loading">
<div class="loader"></div>
</div>
<script src="flutter_bootstrap.js" async></script>
</body>

可自行更改样式表中的加载进度条颜色等属性