我已阅读此https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps。
我的问题是将数据从现有的原生 android 应用程序传递到 flutter 模块(例如:令牌、用户名...等)。所以,我想问一下,有没有什么办法可以在现有的native app中的native code和flutter module中的code之间传递数据?
比如有两个页面,A和B,A是用Java代码写的,B嵌入了flutter view,我在B中没有找到从A传数据到flutter view的方法。
public class TwoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.two_activity);
//this params passed from HomeActivity
String params = getIntent().getStringExtra("params");
FrameLayout rootView = findViewById(R.id.container);
View flutterView = Flutter.createView(this, getLifecycle(), "service");
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
rootView.addView(flutterView, layoutParams);
}
}
Run Code Online (Sandbox Code Playgroud)
这是 main.dart
void main() => runApp(chooseWidget(window.defaultRouteName));
Widget chooseWidget(String route) {
switch(route) {
case 'service':
return MyFlutterView();
}
}
class MyFlutterView extends StatelessWidget { …Run Code Online (Sandbox Code Playgroud) 在xcode9.0中,我向storyboard添加了一个tableview,当我将tableview样式切换为分组,xcode崩溃时.
在HTML中:
<ion-content class="bg-style">
Run Code Online (Sandbox Code Playgroud)
在variables.scss中:
.bg-style {
background-color: #f5f0eb;
}
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用,但它可以在其他标签等工作<a> <div>,当我把样式文件(.scss,如test.scss)放在与html文件相同的路径时,它也可以正常工作我不知道我的问题是否清楚,谢谢你的帮助.
<ion-input placeholder="please input" clearInput></ion-input>
我想更改占位符的颜色,不应该影响其他页面.
Flutter(通道大师,v1.9.1-pre.58)
我编写了一个自定义本机视图并通过 flutter 嵌入视图使用它。然后我设置io.flutter.embedded_views_preview为truein Info.plist。它在 iOS 模拟器中运行良好,但当我在 iPhone 上运行时,只显示黑屏。当我删除 io.flutter.embedded_views_preview时它可以显示其他小部件Info.plist,但这也导致嵌入视图无法显示。