Flutter_use 项目教程
flutter_usePlay Flutter Hooks.项目地址:https://gitcode.com/gh_mirrors/flut/flutter_use
1. 项目的目录结构及介绍
Flutter_use 项目的目录结构如下:
flutter_use/
├─ custom_builder/
│ ├─ easy_p/
│ ├─ easy_p_counter/
│ ├─ easy_p_counter_global/
│ ├─ span_page/
│ │ ├─ span_one/
│ │ └─ span_two/
│ └─ test_notifier/
├─ lib/
│ ├─ module/
│ │ ├─ common/
│ │ │ └─ widget/
│ │ ├─ example/
│ │ │ ├─ bloc/
│ │ │ │ ├─ counter_bloc/
│ │ │ │ ├─ counter_cubit/
│ │ │ │ ├─ custom_builder/
│ │ │ │ ├─ easy_c/
│ │ │ │ ├─ easy_c_counter/
│ │ │ │ ├─ span_page/
│ │ │ │ │ ├─ span_one/
│ │ │ │ │ └─ span_two/
│ │ │ │ └─ stream/
│ │ └─ ...
│ └─ ...
└─ ...
目录结构介绍
-
custom_builder: 包含自定义构建器的相关代码。
- easy_p: 简单示例代码。
- easy_p_counter: 计数器示例代码。
- easy_p_counter_global: 全局计数器示例代码。
- span_page: 跨页面示例代码。
- span_one: 跨页面示例代码的一部分。
- span_two: 跨页面示例代码的一部分。
- test_notifier: 测试通知器示例代码。
-
lib: 项目的主要代码库。
- module: 模块代码。
- common: 通用组件和工具。
- widget: 通用小部件。
- example: 示例代码。
- bloc: BLoC 模式示例代码。
- counter_bloc: 计数器 BLoC 示例。
- counter_cubit: 计数器 Cubit 示例。
- custom_builder: 自定义构建器示例。
- easy_c: 简单示例代码。
- easy_c_counter: 计数器示例代码。
- span_page: 跨页面示例代码。
- span_one: 跨页面示例代码的一部分。
- span_two: 跨页面示例代码的一部分。
- stream: 流示例代码。
- bloc: BLoC 模式示例代码。
- common: 通用组件和工具。
- module: 模块代码。
2. 项目的启动文件介绍
项目的启动文件通常是 lib/main.dart
。这个文件是 Flutter 应用程序的入口点,负责初始化应用并启动主界面。
import 'package:flutter/material.dart';
import 'package:flutter_use/app.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Use',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
启动文件介绍
- main 函数: 应用程序的入口点,调用
runApp
函数启动应用。 - MyApp 类: 应用的根小部件,定义应用的标题、主题和主页。
3. 项目的配置文件介绍
项目的配置文件通常包括 pubspec.yaml
和 analysis_options.yaml
。
pubspec.yaml
pubspec.yaml
文件用于定义项目的依赖、资源和其他配置。
name: flutter_use
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_hooks: ^0.
flutter_usePlay Flutter Hooks.项目地址:https://gitcode.com/gh_mirrors/flut/flutter_use