如何根据不同的URL在leading
中显示不同的AppBar
小部件?
答案 0 :(得分:0)
@override
Widget build(BuildContext context) {
Widget widget;
switch (url) {
case "url_1":
widget = Widget1();
break;
case "url_2":
widget = Widget2();
break;
case "url_3":
widget = Widget3();
break;
default:
widget = DefaultWidget();
}
return Scaffold(
appBar: AppBar(leading: widget),
);
}
答案 1 :(得分:0)
CopsOnRoad答案不错,但是如果您需要从构建配置中获取网址,请查看https://flutter.dev/docs/deployment/flavors