alibaba / alibaba/flutter_boost

如何在flutter的main函数中获取到native传过来的args

Open
#1,733 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
7.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

我使用了以下方法,在setup时候 传递参数,想在flutter的main函数接收,但是没有效果
android代码:
```
String[] shellArgs ={"--model","debug"};
FlutterBoostSetupOptions options = new FlutterBoostSetupOptions.Builder().shellArgs(shellArgs).build();
FlutterBoost.instance().setup(mApplication, new FlutterBoostDelegate() {
@Override
public void pushNativeRoute(FlutterBoostRouteOptions options) {
}

@Override
public void pushFlutterRoute(FlutterBoostRouteOptions options) {
}
}, engine -> {
Logger.i(TAG, "init: FlutterBoost end");
},options);
```
flutter代码:
```
void main(List args) {
Log.global().i("[Flutter main]flutter args1 is:", args.toString());
};
```
请问这种方式能实现吗?或者有其方式解决这个问题吗?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Android FlutterBoost setup call using shellArgs and the Dart main(List args) entry point shown in the issue. Reproduce the argument handoff with the provided --model debug values, then check whether FlutterBoost supports exposing them there; done means the supported behavior or limitation is verified and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, flutter
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.