push<T> method
跳转页面
page 需要跳转的页面
finishCurr 是否需要结束当前页面,注意确认当前页面是否可退出
Implementation
Future<T?> push<T>(Widget page, {bool finishCurr = false}) async {
if (isUseful()) {
if (finishCurr) {
try {
return await Navigator.pushAndRemoveUntil(this,
CupertinoPageRoute(builder: (context) => page), (route) => false);
} catch (e) {
Log.d("pushAndRemoveUntil发生异常", error: e);
try {
return Navigator.of(this).push(
CupertinoPageRoute(builder: (context) => page),
);
} catch (e) {
Log.d("push发生异常", error: e);
}
}
} else {
try {
return Navigator.of(this).push(
CupertinoPageRoute(builder: (context) => page),
);
} catch (e) {
Log.d("push发生异常", error: e);
}
}
}
return null;
}