Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用了showWeuiLoadingToast后Navigator.pop就返回不了返回值了 #8

Closed
ni-ken opened this issue Jan 15, 2019 · 11 comments
Closed

Comments

@ni-ken
Copy link

ni-ken commented Jan 15, 2019

var hide = showWeuiLoadingToast(context: context, message: Text("请稍后"));
await Future.delayed(Duration(seconds: 2));
hide();
Navigator.pop(context, 'Yep');====>这个‘Yep'就返回不到上个页面了

@Im-Kevin
Copy link
Owner

Toast 不应该有返回值的

:octocat: From gitme iOS

@Im-Kevin
Copy link
Owner

还有你这个要么在toast 完成前,要么完成后,toast 是占有pop 的

:octocat: From gitme iOS

@ni-ken
Copy link
Author

ni-ken commented Jan 16, 2019

当然不是要返回toast的值,假设有这样的应用场景,页面B做了一些耗时的事后自动返回页面A,这时先显示一个loading toast,然后发个http请求等回应,然后根据回应传递不同参数给下个页面,这时候这样写就会有问题,从流程角度看,有两个pop应该顺序执行,但toast的pop会比页面的pop延迟一帧

@Im-Kevin
Copy link
Owner

是的,因为我里面做了个回调处理,不是即时相应,我晚点修改一下,返回一个future``

@ni-ken
Copy link
Author

ni-ken commented Jan 16, 2019

我昨天稍微改了下,这样用的
var hide = showWeuiToast();===>返回内部那个future
....
await hideWeuiToast(hide);===>这里面等等future完成,调用callback。

另外,如果你用overlay来实现的话,为什么还要push和pop?

@Im-Kevin
Copy link
Owner

这里是当时做的时候没有直接使用Overlay,之后会改过的,因为也是个摸索的过程

@ni-ken
Copy link
Author

ni-ken commented Jan 16, 2019

嗯嗯。理论上来说toast是和页面无关的,即使页面跳转了,只要toast还活着就能显示。dialog是显示在当前页面的,页面关了dialog也关了。所以toast之类的用overlay会好一点。
非常期待你的修改版本和其他的作品。

@Im-Kevin
Copy link
Owner

问题已修复,你更新下版本看看

@ni-ken
Copy link
Author

ni-ken commented Jan 19, 2019

谢谢,已使用。
但是又发现一个新问题。当我在进入一个页面时想先展示loading,同时在异步加载数据,我在initState()里调用了showWeuiLoadingToast,结果程序崩溃了

@Im-Kevin
Copy link
Owner

initState的时候context 是不是还没初始化好

:octocat: From gitme iOS

@Im-Kevin
Copy link
Owner

如果可以的话我就关掉这个issue

:octocat: From gitme iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants