小编Dav*_*vid的帖子

如何将数据从本机应用程序传递到 Flutter?

我已阅读此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)

android flutter

10
推荐指数
1
解决办法
7809
查看次数

xcode9.0,在storyboard中,当我将tableview样式切换为分组时,xcode崩溃了

在xcode9.0中,我向storyboard添加了一个tableview,当我将tableview样式切换为分组,xcode崩溃时.

tableview xcode9

9
推荐指数
2
解决办法
446
查看次数

ionic2:无法在variables.scss中设置<ion-content>背景颜色

在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文件相同的路径时,它也可以正常工作我不知道我的问题是否清楚,谢谢你的帮助.

styles sass ionic2

7
推荐指数
2
解决办法
1万
查看次数

如何在离子输入中更改占位符的颜色?

<ion-input placeholder="please input" clearInput></ion-input>

我想更改占位符的颜色,不应该影响其他页面.

input ionic2

2
推荐指数
1
解决办法
9695
查看次数

如果设置 io.flutter.embedded_views_preview 为 true,则无法正常运行 flutter 项目

Flutter(通道大师,v1.9.1-pre.58)

我编写了一个自定义本机视图并通过 flutter 嵌入视图使用它。然后我设置io.flutter.embedded_views_previewtruein Info.plist。它在 iOS 模拟器中运行良好,但当我在 iPhone 上运行时,只显示黑屏。当我删除 io.flutter.embedded_views_preview时它可以显示其他小部件Info.plist,但这也导致嵌入视图无法显示。

ios flutter

2
推荐指数
1
解决办法
4997
查看次数

标签 统计

flutter ×2

ionic2 ×2

android ×1

input ×1

ios ×1

sass ×1

styles ×1

tableview ×1

xcode9 ×1