Flutter & flutter_boost开发iOS混合开发项目问题记录;iOS远程依赖Flutter Module组件代码;

Overview

[TOC]

这个仓库主要有2部分,整理了如何在iOS项目导入FlutterModule组件代码,以及整理开发过程中遇到的一些问题和对应的解决方案。

在iOS项目依赖FlutterModule组件代码

依赖Flutter组件代码的分为本地依赖、远程依赖2种。下面介绍的前3种是本地依赖,同时也是官方推荐的方法,在开发文档Adding Flutter to iOS 有详细介绍。简单的说本地依赖就是直接依赖本机的编译产物,需要每个开发人员都安装Flutter开发环境,同时编译产物会导出到FlutterModule或者iOS项目的Git目录下,依赖指向的也是相对路径,加上Flutter版本不一致就容易造成Git冲突。远程依赖则是将Flutter编译得到的相关framework都推到云端git,在iOS项目通过CocoaPods远程依赖,也就不用要求所有人都安装Flutter开发环境,Flutter Module 、Flutter编译产物、Native 都有独立的Git,某端的更改不会直接影响到另一端。

iOS项目依赖Flutter module:

构建脚本:

基于远程依赖Flutter Module组件库编译产物(多方案版) 方案0x05 写的脚本也已经完成,实现了Futter编译到产物分拣上传的功能,其它的方案也可以参考这个脚本,远程依赖Flutter Module组件库构建脚本

相关脚本:

另外将Flutter组件库添加到iOS项目中,流程中会涉及到2个关键脚本,一个ruby脚本podhelper.rb, 另一个是shell脚本xcode_backend.sh,我看的时候加了一些注解。

  • podhelper.rb 注解,此脚本主要的功能是导入Flutter、App、FlutterPluginRegistrant和其它第三方库的本地依赖,另外设置一个Build Phases执行脚本,在编译Xcode项目时执行xcode_backend.sh脚本。
  • xcode_backend.sh 注解,此脚本的主要功能是根据编译模式和CPU架构 编译/合成 Flutter相关的framework动态库。
  • 待研究:flutter build ios-framework 对应的源码,路径是flutter/packages/flutter_tools/lib/src/commands/build_ios_framework.dart

flutter_boost混合开发挖坑记录

我们的项目使用flutter_boost来实现iOS & Flutter混合项目开发,目前也已经适配到flutter_boost v3.0.0FlutterBoost3.0.0新增一个Flutter控制器容器,但我们项目有统一的控制器基类,为了统一控制器页面的某些特性和接口功能, 我在FlutterBoost的容器上又封装了一层控制器容器,导致在开发过程遇到了深浅色适配和内存泄漏的问题。

深浅色适配和Push/Present进入Flutter页面是我在项目开发中真实用到的场景,在Demo中我还原了这2个场景及遇到的问题,给原生页面和Flutter页面都适配了深浅色,其中的搜索页SearchPage就是Flutter页面,而APP的主页就是原生页面(可以切换深浅色),另外进入SearchPage采用了Push、Present 2种转场方式,以对比效果。

另外我在FBFlutterViewContainer 基础上自定义一个Flutter控制器容器,最后所有的Flutter页面都由FlutterModuleViewController承载,而FBFlutterViewContainer则添加在容器FlutterModuleViewController上,但是2者不是继承关系,而是父子控制器的关系。之所以这么做是为了统一控制器页面的某些特性和接口功能。

    FlutterModuleViewController.m

    self.flutterContainer.view.frame = self.view.bounds;
    [self.view insertSubview:self.flutterContainer.view atIndex:0];
    [self addChildViewController:self.flutterContainer];

Flutter控制器容器

问题1.首次进入Flutter页面出现空白

首次进入Flutter页面,由于Flutter预热时会出现短暂的空白,点击查看细节和解决方案

问题图

问题2.在原生页面切换深浅色后进入Flutter页面会先渲染上一次的配色模式

Flutter适配深浅色后在切换深浅色模式时出现渲染异常,点击查看细节和解决方案

问题3. 自定义Flutter(Boost)容器后,Flutter页面退出后没有调用dispose,出现内存泄漏

由于我在FBFlutterViewContainer 基础上自定义了Flutter控制器容器,导致在退出页面时没有触发notifyWillDealloc,致使Flutter页面没有得到释放。点击查看细节和解决方案

You might also like...
Flutter package for detecting NSFW images and videos using native implementation

Flutter NSFW 1- Download, tflite modle and put it in assets folder 2 - Add the path of the tfliet to pubspec.yaml 3 - Read the file using path_provide

A apple search ads attribution plugin for flutter

A apple search ads attribution plugin for flutter

Projeto utilizando Flutter para desenvolver uma aplicação com o objetivo de gerenciar uma lista de livros, como se fosse uma biblioteca, sendo possível adicionar, editar e excluir livros.

todo_list_flutter A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Mi Card App for Android & IOS in Flutter
Mi Card App for Android & IOS in Flutter

Mi Card Our Goal Now that you've seen how to create a Flutter app entirely from scratch, we're going to go further and learn more about how to design

Magic 8Ball App for Android & IOS in Flutter
Magic 8Ball App for Android & IOS in Flutter

Magic 8 Ball 🎱 Our Goal The objective of this challenge is to solidify what you've learn't in the Dicee tutorial. This app will guide you through the

Dicee App for Android & IOS in Flutter
Dicee App for Android & IOS in Flutter

Dicee 🎲 Our Goal The objective of this tutorial is to introduce you to the core programming concepts that will form the foundation of most of the app

Flutter plugin to display VGS card info using TextView or View

VGS Card Info Flutter plugin to display VGS Card info using TextView or View Installation Add the dependency in your pubspec.yaml vgscardinfo: git

Flutter Piano Audio Detection implemented with Tensorflow Lite Model (Google Magenta)
Flutter Piano Audio Detection implemented with Tensorflow Lite Model (Google Magenta)

FlutterPianoAudioDetection Plugin Flutter Piano Audio Detection implemented with Tensorflow Lite Model (Google Magenta) Android Implementation iOS/iPa

 Flutter Apple Product Store App UI Home Page With Getx
Flutter Apple Product Store App UI Home Page With Getx

Flutter Apple Product Store App UI Home Page With Getx A new Flutter UI Project on my Youtube Channel . About The Project Create a beautiful Flutter U

A new Flutter plugin that uses OpenVpn

flutter_openvpn A new Flutter plugin that uses OpenVpn. Installation Depend on it Add this to your package's pubspec.yaml file: dependencies: flutte

A Flutter powered messaging app including Firebase registration, authentication and group messaging feature.

we_chat A Flutter powered messaging app including Firebase registration, authentication and group messaging feature. Getting Started This project is a

Klab Academy, example of calling APIs in flutter

klab A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Aplicativo desenvolvido em Flutter que gera frases aleatórias

frases_do_dia Aplicativo desenvolvido em Flutter que gera Frases aleatórias Getting Started This project is a starting point for a Flutter application

I'm trying to make Flutter based Audio Unit Extensions possible.
I'm trying to make Flutter based Audio Unit Extensions possible.

Flutter AUv3 Audio Unit Error Demo Motivation We are the developers of Audanika, a professional MIDI Controller app written in Flutter. Many of our us

Fluetooth - Flutter library for sending bytes to Bluetooth devices on Android/iOS

A Flutter library for sending bytes to Bluetooth devices. Available on Android a

Resource monitor - A flutter plugin for Android and IOS to monitor CPU and RAM usage of device.

resource_monitor A flutter plugin for Android and IOS to monitor CPU and RAM usage of device. TODO Implement Android Side of this plugin. Add listener

Starlight epub viewer - Epub viewer for flutter
Starlight epub viewer - Epub viewer for flutter

Starlight Epub Viewer starlight_epub_viewer is an epub ebook reader that encapsu

Near Procedure Call between flutter and native.

npcx A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package that includes

FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app
FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app

native_drag_n_drop A package that allows you to add native drag and drop support

Owner
溪枫狼
iOS Developer。
溪枫狼
A apple search ads attribution plugin for flutter

A apple search ads attribution plugin for flutter

liam 0 Oct 27, 2021
Mi Card App for Android & IOS in Flutter

Mi Card Our Goal Now that you've seen how to create a Flutter app entirely from scratch, we're going to go further and learn more about how to design

Ruksar Ahmed 0 Nov 6, 2021
Magic 8Ball App for Android & IOS in Flutter

Magic 8 Ball ?? Our Goal The objective of this challenge is to solidify what you've learn't in the Dicee tutorial. This app will guide you through the

Ruksar Ahmed 0 Nov 6, 2021
Near Procedure Call between flutter and native.

npcx A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package that includes

null 0 Jun 17, 2022
FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app

native_drag_n_drop A package that allows you to add native drag and drop support

Alex Rabin 21 Dec 21, 2022
Example of a Flutter app in the status bar.

flutter_in_status_bar Example of a Flutter app in the status bar. This is the default counter app from Flutter but instead of running in a NSWindow it

Jochum van der Ploeg 40 Nov 29, 2022
Flutter openvpn - A new Flutter plugin that uses OpenVpn

flutter_openvpn A new Flutter plugin that uses OpenVpn. Installation Depend on i

Ferdi Gökdemir 0 Jan 8, 2022
Realtime yoga pose detection and classification plugin for Flutter using MLKit

ML Kit Pose Detection Plugin Flutter plugin for realtime pose detection using MLKit's Blazepose. License Copyright (c) 2021 Souvik Biswas, Bharat Bira

Souvik Biswas 8 May 5, 2022
Corona Virus Tracker & Advices App with Flutter

Corona Virus Tracker & Advices App with Flutter Try the web app dev preview https://alfian-flutter-coronatracker.firebaseapp.com/ Features Current sta

Alfian Losari 88 Dec 19, 2022
A Flutter plugin (platform channel with Swift) to get the current app name and also bring our app to the front.

window_to_front A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package th

Minas Giannekas 1 Nov 13, 2021