鸿蒙Flutter三方库适配指南:Flutter相关知识基础
Flutter 三层结构
Dart 层(Framework 层)
使用 Dart 语言 编写
提供了 UI 框架(widgets、material、cupertino) 和 渲染、手势、动画 等上层 API
面向开发者,负责 业务逻辑 与 界面搭建
C/C++ 层(Engine 层)
Flutter 的 引擎核心,主要用 C/C++ 编写
包含 Skia/Impeller 图形渲染引擎、文本排版(libtxt)、Dart VM
负责 图形渲染、文本排版、GPU 加速 等底层性能相关工作
Platform-dependent 层(Embedder 层)
负责与 宿主操作系统(Android、iOS、HarmonyOS、Windows、macOS、Linux) 的交互
提供 事件处理(输入、手势)、系统 API 调用、插件通信(Platform Channels)
不同平台有各自的 embedder 实现,使 Flutter 可以运行在不同系统上
Dart 语言基础知识
Dart 是一种面向对象的编程语言,Flutter 使用 Dart 作为其主要开发语言。
// 变量声明
String hi = 'hello';
// 常量声明
constString hello = 'hello';
// 类定义
class Person {
String name = '';
int age = 0;
Person(String n, int a) {
name = n;
age = a;
}
String getName() {
return name;
}
}
Person p1 = Person('Alice', 25);
注组
在 Flutter 中,通常使用注解来标识组件和入口点:
// 主程序入口
void main() => runApp(MyApp());
// 组件装饰器
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(title: Text('Hello')),
body: Center(child: Text('Hello World')),
),
);
}
}
Flutter 与 ArkUI 对比
|
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
语法对比
|
|
|
|---|---|
![]() |
![]() |
参考资料
- Flutter架构概览[1]
- ArkUI[2]
[2] ArkUI: https://developer.huawei.com/consumer/cn/arkui/
评论
- 目前还没评论,等你发挥!

起点课堂会员权益






