flutter_boilerplate_supabase

包含用于 Flutter 的 Superbase 设置的样板代码。

Flutter

规范

  • 本地化
  • Get 包 导航设置
  • 资产相关设置(图像、图标、颜色)
  • 已安装的测试包
  • Supabase 设置

文件夹结构

├── android
├── build
├── ios
├── lib
│   ├── generated
│   │   ├── intl
│   │   │   ├── messages_all.dart
│   │   │   ├── messages_en.dart
│   │   │   └── messages_ko.dart
│   │   └── l10n.dart
│   ├── l10n
│   │   ├── intl_en.arb
│   │   └── intl_ko.arb
│   ├── main.dart
│   ├── models
│   │   └── sample.dart
│   ├── screens // <- or pages
│   │   └── home.dart
│   ├── utils
│   │   └── asset.dart
│   └── widgets // <- or components
│       └── sample.dart
├── res
│   ├── icons
│   │   └── logo.png
│   ├── images
│   │   └── logo.png
│   ├── fonts // <- If you want, you have to make it here yourself.
├── test
│   └── widget_test.dart
├── analysis_options.yaml
├── flutter_boilerplate.iml
├── pubspec.lock
├── pubspec.yaml
└── README.md

依赖项

  # dev_dependencies
  test: ^1.17.12
  mockito: ^5.0.17
  build_runner: ^2.1.7
  integration_test: ^0.8.1

  # dependencies
  intl: ^0.17.0
  get: ^4.6.1
  cupertino_icons: ^1.0.2

运行项目

pub get
flutter run ios
flutter run android

本地化

该存储库使用 Flutter 官方网站 推荐的 arb 进行本地化。

要使用它,您需要在 VSCode 或 Android Studio 中安装 Flutter Intl 扩展。

您可以通过以下链接进行安装。

安装 Flutter Intl 后,修改 arb 文件时会自动创建一个 dart 文件。

有关此方面的姿势信息,请查看下载链接中的文档。
对于韩国用户,您可以在 此链接 上查看。

如何使用本地化

import 'package:intl/intl.dart';
...

Text(Intl.message('appName'))

或者

import 'package:flutter_boilerplate/generated/l10n.dart';
...

Text(S.of(context))

资源

以下相关内容称为资源。

  • 图片
  • 图标
  • 字体

与资源相关的内容在 res 文件夹下创建。

└── res
    ├── icons
    │   └── logo.png
    ├── images
    │   └── logo.png
    └── fonts // <- If you want, you have to make it here yourself.

如何使用资源

要使用图像或图标,可以使用如下方式。

import 'package:flutter_boilerplate/utils/asset.dart' as asset;
...

Image(
  image: asset.Images.logo,
)

GitHub

查看 Github