我做了一個飛鏢遷移以將我的專案更新為空安全。我有幾個問題需要排序,因為它是一個舊專案。然而,有一件事讓我很困惑,無法想出辦法。
我正在使用
我意識到該函式實際上是無效的,
但我需要回傳一個 Widget。我曾嘗試添加 try 和 catch 塊,但什么也沒做。
Widget showTopBarErrorWidget({required context, String? messageArg}) {
try {
showTopSnackBar(
context,
CustomSnackBar.error(
message: messageArg ??
"Error while starting the session Plans. Please try again",
),
displayDuration: Duration(seconds: 5));
} on Exception catch (e) {
print(e);
rethrow;
}
}
uj5u.com熱心網友回復:
正如h8moss所說,您沒有任何可回傳的內容,showTopBarErrorWidget因此洗掉 Widget 回傳型別并使其無效
void showTopBarErrorWidget({required context, String? messageArg}) {
該showTopSnackBar反正會執行,無需回傳,或什么的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/390020.html
