Flutter/Dart - 透明背景直到 Future 到来?
Flutter/Dart - Transparent Background until Future arrives?
我正在尝试获取一个 PageView.Builder
,它是使用来自网络的数据构建的。当我尝试从另一个页面滑动到它时,我得到一个白色背景,它似乎充当占位符,直到来自 Future
的网络数据到达。我想要的是原始页面在构建页面之前在后台保持可见。但是,尽管我已经尝试了所有我能想到的方法,背景仍然是白色,直到 Future
到达填充 PageView
。在它到达之前,我怎样才能获得清晰的或至少降低不透明度的占位符?
我使用 CircularProgressIndicator 作为占位符,但它不仅看起来很糟糕(滑动会在所有方向上炸毁它),而且背景仍然顽固地不透明和白色。我还尝试了具有透明颜色的 Container
,但它只是覆盖了 Future 的白色背景。我怎样才能去掉不透明的白色背景,它就像 Future
?
的占位符
这就是未来;
FutureBuilder<List<ReplyContent>> replyStage({String replyid}) {
return FutureBuilder<List<ReplyContent>>(
future: downloadReplyJSON(replyid),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<ReplyContent> replycrafts = snapshot.data;
return StageBuilderVR(replycrafts, Globals.masterTitle);
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return
Container(
color: Colors.transparent,
);
}
);
}
所以我决定完全采用不同的方法并创建一个虚拟页面,它以图形方式镜像前一页,其中包含前一页的所有图形元素和 none 代码。我用这个虚拟对象代替了 CircularProgressIndicator。这可能不是正确或最好的方法,但它似乎运作良好。我对结果很满意。
FutureBuilder<List<ReplyContent>> replyStage({String replyid, String replytitle}) {
return new FutureBuilder<List<ReplyContent>>(
future: downloadReplyJSON(),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<ReplyContent> replycrafts = snapshot.data;
return StageBuilderVR(replycrafts, replytitle);
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return DummyPage();
},
);
}
我正在尝试获取一个 PageView.Builder
,它是使用来自网络的数据构建的。当我尝试从另一个页面滑动到它时,我得到一个白色背景,它似乎充当占位符,直到来自 Future
的网络数据到达。我想要的是原始页面在构建页面之前在后台保持可见。但是,尽管我已经尝试了所有我能想到的方法,背景仍然是白色,直到 Future
到达填充 PageView
。在它到达之前,我怎样才能获得清晰的或至少降低不透明度的占位符?
我使用 CircularProgressIndicator 作为占位符,但它不仅看起来很糟糕(滑动会在所有方向上炸毁它),而且背景仍然顽固地不透明和白色。我还尝试了具有透明颜色的 Container
,但它只是覆盖了 Future 的白色背景。我怎样才能去掉不透明的白色背景,它就像 Future
?
这就是未来;
FutureBuilder<List<ReplyContent>> replyStage({String replyid}) {
return FutureBuilder<List<ReplyContent>>(
future: downloadReplyJSON(replyid),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<ReplyContent> replycrafts = snapshot.data;
return StageBuilderVR(replycrafts, Globals.masterTitle);
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return
Container(
color: Colors.transparent,
);
}
);
}
所以我决定完全采用不同的方法并创建一个虚拟页面,它以图形方式镜像前一页,其中包含前一页的所有图形元素和 none 代码。我用这个虚拟对象代替了 CircularProgressIndicator。这可能不是正确或最好的方法,但它似乎运作良好。我对结果很满意。
FutureBuilder<List<ReplyContent>> replyStage({String replyid, String replytitle}) {
return new FutureBuilder<List<ReplyContent>>(
future: downloadReplyJSON(),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<ReplyContent> replycrafts = snapshot.data;
return StageBuilderVR(replycrafts, replytitle);
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return DummyPage();
},
);
}