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

请问可以在原生的主线程调用原生函数吗? #85

Open
ruiq opened this issue Dec 16, 2021 · 1 comment
Open

请问可以在原生的主线程调用原生函数吗? #85

ruiq opened this issue Dec 16, 2021 · 1 comment

Comments

@ruiq
Copy link

ruiq commented Dec 16, 2021

大佬好。
我在调用iOS的方法时,方法内部使用了一些UIView,但是报错了,说是不在主线程。
所以想问一下,dart -> native,默认会在非主线程调用吗?怎么样可以让这个调用发生在主线程呢?

@yulingtianxia
Copy link
Member

yulingtianxia commented Dec 16, 2021

默认是同步调用到 Native,那么此时是在 flutter-ui 线程,并不是 iOS 的主线程。所以 DartNative 也支持切线程(GCD),比如这个例子:

.performAsync(SEL('currentThread'), onQueue: DispatchQueue.global())

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