Flutter 子模块

Posted wzj_what_why_how

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter 子模块相关的知识,希望对你有一定的参考价值。

添加 flutter子模块到已有项目

  • 将 Flutter module 集成到 android 项目: https://flutter.cn/docs/development/add-to-app/android/project-setup

基础步骤

  • 创建模块
    • 在已有项目中执行创建出flutter module:flutter create -t module kp_flutter
    • flutter clean
    • flutter pub get
  • 模块依赖
    • 将 Flutter 模块作为子项目添加到宿主应用的 settings.gradle 中。

      • setBinding(new Binding([gradle: this])) // new
        evaluate(new File( // new
        settingsDir.parentFile, // 如果是跟setting.class同级的话,直接settingsDir就可以了。否则,parentFile对那个下级目录。
        ‘my_flutter/.android/include_flutter.groovy’ // 通过
        ))
    • 在app中引入对 Flutter 模块的依赖:

      • implementation project(‘:flutter’)

将子模块作为子仓库部署的步骤

  • 先去创建个空的远程仓库
  • git init 然后将远程仓库clone到本地
  • 将从远程仓库拉下来的文件移动到对应的flutter module。
  • 然后就可以commit 并 push 到远程仓库了。不过此时就要注意哪些是要提交,哪些是没必要提交的需要添加到.gitignore文件配置中。

.gitignore配置

这是官方的配置模板:https://github.com/flutter/flutter/blob/master/.gitignore

`# Miscellaneous
	*.class
	*.lock
	*.log
	*.pyc
	*.swp
	.DS_Store
	.atom/
	.buildlog/
	.history
	.svn/
	
	# IntelliJ related
	*.iml
	*.ipr
	*.iws
	.idea/
	
	# Visual Studio Code related
	.classpath
	.project
	.settings/
	.vscode/
	
	# Flutter repo-specific
	/bin/cache/
	/bin/internal/bootstrap.bat
	/bin/internal/bootstrap.sh
	/bin/mingit/
	/dev/benchmarks/mega_gallery/
	/dev/bots/.recipe_deps
	/dev/bots/android_tools/
	/dev/devicelab/ABresults*.json
	/dev/docs/doc/
	/dev/docs/flutter.docs.zip
	/dev/docs/lib/
	/dev/docs/pubspec.yaml
	/dev/integration_tests/**/xcuserdata
	/dev/integration_tests/**/Pods
	/packages/flutter/coverage/
	version
	analysis_benchmark.json
	
	# packages file containing multi-root paths
	.packages.generated
	
	# Flutter/Dart/Pub related
	**/doc/api/
	.dart_tool/
	.flutter-plugins
	.flutter-plugins-dependencies
	**/generated_plugin_registrant.dart
	.packages
	.pub-cache/
	.pub/
	build/
	flutter_*.png
	linked_*.ds
	unlinked.ds
	unlinked_spec.ds
	
	# Android related
	**/android/**/gradle-wrapper.jar
	.gradle/
	**/android/captures/
	**/android/gradlew
	**/android/gradlew.bat
	**/android/local.properties
	**/android/**/GeneratedPluginRegistrant.java
	**/android/key.properties
	*.jks
	
	# ios/XCode related
	**/ios/**/*.mode1v3
	**/ios/**/*.mode2v3
	**/ios/**/*.moved-aside
	**/ios/**/*.pbxuser
	**/ios/**/*.perspectivev3
	**/ios/**/*sync/
	**/ios/**/.sconsign.dblite
	**/ios/**/.tags*
	**/ios/**/.vagrant/
	**/ios/**/DerivedData/
	**/ios/**/Icon?
	**/ios/**/Pods/
	**/ios/**/.symlinks/
	**/ios/**/profile
	**/ios/**/xcuserdata
	**/ios/.generated/
	**/ios/Flutter/.last_build_id
	**/ios/Flutter/App.framework
	**/ios/Flutter/Flutter.framework
	**/ios/Flutter/Flutter.podspec
	**/ios/Flutter/Generated.xcconfig
	**/ios/Flutter/ephemeral
	**/ios/Flutter/app.flx
	**/ios/Flutter/app.zip
	**/ios/Flutter/flutter_assets/
	**/ios/Flutter/flutter_export_environment.sh
	**/ios/ServiceDefinitions.json
	**/ios/Runner/GeneratedPluginRegistrant.*
	
	# macOS
	**/macos/Flutter/GeneratedPluginRegistrant.swift
	**/macos/Flutter/ephemeral
	
	# Coverage
	coverage/
	
	# Symbols
	app.*.symbols
	
	# Exceptions to above rules.
	!**/ios/**/default.mode1v3
	!**/ios/**/default.mode2v3
	!**/ios/**/default.pbxuser
	!**/ios/**/default.perspectivev3
	!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
	!/dev/ci/**/Gemfile.lock`
开发者涨薪指南 48位大咖的思考法则、工作方式、逻辑体系

以上是关于Flutter 子模块的主要内容,如果未能解决你的问题,请参考以下文章

SpringBoot多模块项目子模块controller未加载问题

Sql查询树状结构下级子节点的数量

SpringBoot子模块相互依赖打包

ExtJs--05--给window组件加入功能条以及子组件获取上级或下级组件的属性和方法

MySQL递归查询,实现上下级联查,父子级查询

(转)Jquery获取上级下级或者同级的元素