国产亚洲欧美人成在线,免费视频爱爱太爽了无码,日本免费一区二区三区高清视频 ,国产真实伦对白精彩视频

歡迎您光臨深圳塔燈網(wǎng)絡(luò)科技有限公司!
電話圖標(biāo) 余先生:13699882642

網(wǎng)站百科

為您解碼網(wǎng)站建設(shè)的點(diǎn)點(diǎn)滴滴

Android工程集成flutter

發(fā)表日期:2018-11 文章編輯:小燈 瀏覽次數(shù):2659

Android工程集成flutter

官方方案

https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps

第一個(gè)步:
新建一個(gè)標(biāo)準(zhǔn)的APP工程testFlutterInAPP,APP目錄下面通過(guò)命令創(chuàng)建flutter模塊工程

flutter create -t module my_flutter

image.png

編譯flutter 代碼生成Android的AAR文件

$ cd .android/ $ ./gradlew flutter:assembleDebug 

AAR 文件生成到.android/Flutter/build/outputs/aar/目錄下面

添加Host APP 依賴flutter module 模塊,在setting.gradle 文件中加入

include ':app' // assumed existing content setBinding(new Binding([gradle: this])) // new evaluate(new File(// new settingsDir.parentFile, // new 'my_flutter/.android/include_flutter.groovy'// new ))

app/build.gradle 增加對(duì)flutter 工程依賴

// testFlutterInAPP/app/build.gradledependencies { implementation project(':flutter') } 

構(gòu)建成功后,執(zhí)行Android的run啟動(dòng)應(yīng)用 ,點(diǎn)擊打開(kāi)flutter 。


image.png

Java 層代碼

 openFlutter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View flutterView = Flutter.createView( MainActivity.this, getLifecycle(), "route1" ); FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(600, 800); layout.leftMargin = 100; layout.topMargin = 200; addContentView(flutterView, layout); } }); 

flutter 代碼

import 'dart:ui';import 'package:flutter/material.dart';void main() => runApp(_widgetForRoute(window.defaultRouteName)); Widget _widgetForRoute(String route) { switch (route) { case 'route1': return new MyApp(); case 'route2': return new MyApp(); default: return Center( child: Text('Unknownroute1 : $route', textDirection: TextDirection.ltr), ); } return new MyApp(); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: 'Flutter Demo 1111' 'Home Page'), ); } }class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key);final String title;@override _MyHomePageState createState() => new _MyHomePageState(); }class _MyHomePageState extends State<MyHomePage> { int _counter = 0;void _incrementCounter() { setState(() {_counter++; }); }@override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text(widget.title), ), body: new Center( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new Text( 'You have pushed the button this many times:', ), new Text( '$_counter', style: Theme.of(context).textTheme.display1, ), ], ), ), floatingActionButton: new FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: new Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } } 

運(yùn)行 flutter 工程 ,進(jìn)入my_flutter 目錄執(zhí)行flutter run 命令

image.png

即可啟動(dòng)flutter ,r == hot reload R == hot restart
q == quit d == detach,

或者啟動(dòng)Android應(yīng)用調(diào)試

image.png

但是,好像DEBUG無(wú)效??

閑魚(yú)方案

連接 https://zhuanlan.zhihu.com/p/40528502


本頁(yè)內(nèi)容由塔燈網(wǎng)絡(luò)科技有限公司通過(guò)網(wǎng)絡(luò)收集編輯所得,所有資料僅供用戶學(xué)習(xí)參考,本站不擁有所有權(quán),如您認(rèn)為本網(wǎng)頁(yè)中由涉嫌抄襲的內(nèi)容,請(qǐng)及時(shí)與我們聯(lián)系,并提供相關(guān)證據(jù),工作人員會(huì)在5工作日內(nèi)聯(lián)系您,一經(jīng)查實(shí),本站立刻刪除侵權(quán)內(nèi)容。本文鏈接:http://jstctz.cn/18082.html
相關(guān)APP開(kāi)發(fā)