Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update labeler #62

Merged
merged 7 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "stable"
}
26 changes: 13 additions & 13 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
ci/cd:
- .github/workflows/*
- any-glob-to-any-file: .github/workflows/*

core:
- lib/core/**
- any-glob-to-any-file: lib/core/**

assets:
- assets/**
- any-glob-to-any-file: assets/**

domain:
- lib/features/**/domain/**
- any-glob-to-any-file: lib/features/**/domain/**

data:
- lib/features/**/data/**
- any-glob-to-any-file: lib/features/**/data/**

presentation:
- lib/features/**/presentation/**
- any-glob-to-any-file: lib/features/**/presentation/**

feature:
- lib/features/**
- any-glob-to-any-file: lib/features/**

shared:
- lib/shared/**
- any-glob-to-any-file: lib/shared/**

test:
- test/**
- any-glob-to-any-file: test/**

documentation:
- README.md
- ./*.md
- any-glob-to-any-file: [README.md, ./*.md]

l10n:
- l10n/**
- any-glob-to-any-file: l10n/**

router:
- lib/app/router/**
- any-glob-to-any-file: lib/app/router/**

2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
with:
flutter_channel: stable
min_coverage: 0
setup: "dart run build_runner build --delete-conflicting-outputs"
setup: "flutter pub global activate very_good_cli && export PATH=$PATH:$HOME/.pub-cache/bin && dart run build_runner build --delete-conflicting-outputs"
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
101 changes: 70 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ Using this template is easy.
5. Rename package name from `dev.adryanev.template` to your liking.
6. Rename the project name from `template` to your need.

Freezed Code generator.

This template optimizes freezed generator only to certain suffixes to improve build time.
The available suffixes are:

- `*.codegen.dart`
- `*.model.dart`
- `*.entity.dart`

For blocs, it automaticly read inside `blocs` directory.

Snackbar Flash

You can use snackbar easily with `FlashCubit`. You can call `context.displayFlash(message)` to show a snackbar.
Expand Down Expand Up @@ -68,9 +57,7 @@ $ flutter run --flavor staging --target lib/main_staging.dart
$ flutter run --flavor production --target lib/main_production.dart
```


_\*Template works on iOS, Android, Web, Linux, and Windows._

*\*Template works on iOS, Android, Web, Linux, and Windows.*

---

Expand Down Expand Up @@ -131,8 +118,8 @@ $ open coverage/index.html

The project is already included some library to speed up the development process.

| Category | Library Name | Link
|--|--|--
| Category | Library Name | Link |
|--|--|--|
| **State management** | `bloc` | <https://pub.dev/packages/bloc> |
| | `flutter_bloc` | <https://pub.dev/packages/flutter_bloc> |
| | `bloc_concurrency` | <https://pub.dev/packages/bloc_concurrency> |
Expand All @@ -143,14 +130,11 @@ The project is already included some library to speed up the development process
| **Languange Feature** | `dartz` | <https://pub.dev/packages/dartz>|
| | `rxdart` | <https://pub.dev/packages/rxdart> |
| | `equatable` | <https://pub.dev/packages/equatable> |
| | `freezed` | <https://pub.dev/packages/freezed> |
| | `freezed_annotation` | <https://pub.dev/packages/freezed_annotation>|
| | `change_case` | <https://pub.dev/packages/change_case> |
| | `intl` | <https://pub.dev/packages/intl>|
| | `uuid` | <https://pub.dev/packages/uuid> |
| | `crypto` | <https://pub.dev/packages/crypto> |
| **JSON** | `json_serializable` | <https://pub.dev/packages/json_serializable> |
| | `json_annotation` | <https://pub.dev/packages/json_annotation> |

| **Dependency Injection** | `get_it` | <https://pub.dev/packages/get_it> |
| | `injectable` | <https://pub.dev/packages/injectable> |
| | `injectable_generator` | <https://pub.dev/packages/injectable_generator> |
Expand All @@ -172,7 +156,7 @@ Notes: **need to install [flutter_gen](https://pub.dev/packages/flutter_gen)*

## Project Structure 🏛

```
```tree
...
assets
├── fonts # Non-Google fonts
Expand Down Expand Up @@ -241,7 +225,7 @@ This project relies on [flutter_localizations][flutter_localizations_link] and f

### Adding Strings

1. To add a new localizable string, open the `app_en.arb` file at `lib/l10n/arb/app_en.arb`.
To add a new localizable string, open the `app_en.arb` file at `lib/l10n/arb/app_en.arb`.

```arb
{
Expand All @@ -253,7 +237,7 @@ This project relies on [flutter_localizations][flutter_localizations_link] and f
}
```

2. Then add a new key/value and description
Then add a new key/value and description

```arb
{
Expand All @@ -269,7 +253,7 @@ This project relies on [flutter_localizations][flutter_localizations_link] and f
}
```

3. Use the new string
Use the new string

```dart
import 'package:template/l10n/l10n.dart';
Expand All @@ -289,26 +273,26 @@ Update the `CFBundleLocalizations` array in the `Info.plist` at `ios/Runner/Info
...

<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>id</string>
</array>
<array>
<string>en</string>
<string>id</string>
</array>

...
```

### Adding Translations

1. For each supported locale, add a new ARB file in `lib/l10n/arb`.
For each supported locale, add a new ARB file in `lib/l10n/arb`.

```
```tree
├── l10n
│ ├── arb
│ │ ├── app_en.arb
│ │ └── app_id.arb
```

2. Add the translated strings to each `.arb` file:
Add the translated strings to each `.arb` file:

`app_en.arb`

Expand All @@ -334,6 +318,61 @@ Update the `CFBundleLocalizations` array in the `Info.plist` at `ios/Runner/Info
}
```

## Migration Guide

This section provides an overview of the breaking changes and steps needed to migrate from the previous version of this template to the latest release.

### 1. Flutter Version & Tooling

- A new file (`.fvmrc`) has been introduced to specify the Flutter version. By default, it locks the project to **stable**. Ensure that [FVM](https://fvm.app/) is installed and run `fvm use` in the project directory if you're using FVM.
- Update your local Flutter SDK to `3.6.x` or higher as specified in `pubspec.yaml` (`sdk: ">=3.6.0 <4.0.0"`).

### 2. Removal of Freezed Code Generation

- All code-generation files such as `*.codegen.dart` for Freezed and JSON serializations have been removed in favor of manually defined classes and sealed classes.
- Replace any references to the older generated `ValueFailure` and `Failure` classes with the new `Failure` or `ValueFailure` sealed classes introduced in `lib/core/domain/failures/failure.dart` and `lib/core/domain/failures/value_failure.dart`.

### 3. Updated Failure and ValueFailure Classes

- The previous Freezed-based `Failure` and `ValueFailure` have been replaced with sealed classes:
- **Failure** now has `localFailure` and `serverFailure`.
- **ValueFailure** includes constructors like `empty`, `multiLine`, `notInRange`, and `invalidUniqueId`.
- Check your test suite to ensure your assertions match the new class names (e.g., `ValueFailureInvalidUniqueId` instead of `ValueInvalidUniqueId`).

### 4. Flash State Refactor

- The `FlashState` class has been refactored from Freezed to a sealed class. If your UI logic relied on the Freezed `.when` or `.maybeWhen` methods, replace them with a `switch/case` or explicit type checks on `FlashAppeared` and `FlashDisappeared`.

### 5. Android Gradle Build Updates

- Gradle has been upgraded from version **7.4** to **8.3**.
- Java source and target compatibility have been set to version 17. Ensure your local environment supports Java 17.
- The plugin management in `android/settings.gradle` and `android/build.gradle` is updated to enable new Gradle features. If you maintain custom build scripts or rely on old plugin versions, update them accordingly.

### 6. Dependency Updates

- Many dependencies have been upgraded (e.g., `bloc`, `flutter_bloc`, `get_it`, `equatable`, etc.). Check `pubspec.yaml` for version changes.
- Remove references to `freezed_annotation` and `json_annotation` if you no longer need them for code generation.

### 7. Build Configuration Changes

- The `build.yaml` file no longer configures builders for Freezed or JSON serializable. If you were depending on those builders, consider using alternative solutions or re-adding them as needed.

### 8. Testing Implications

- Update your test imports to the new `failure.dart` and `value_failure.dart` files.
- If you used specialized methods from Freezed in your tests (`maybeMap`, etc.), replace them with explicit class checks or a `switch` on the new sealed classes.

### 9. Post-Migration Checks

- After updating your code and tests, run `flutter pub get` (or `fvm flutter pub get` if you use FVM) and then execute your test suite (`flutter test`) to ensure everything is working as expected.
- Verify your app runs correctly on both iOS and Android devices or simulators/emulators.
- If you used code generation for features not covered in this project’s new approach, you may need to add alternative solutions or manual code stubs.

---

Following these steps should ensure a smooth transition to the latest Flutter version and the refactored architecture. If you have any questions or encounter issues during migration, feel free to open an issue or reach out to the team!

[coverage_badge]: coverage_badge.svg
[flutter_localizations_link]: https://api.flutter.dev/flutter/flutter_localizations/flutter_localizations-library.html
[internationalization_link]: https://flutter.dev/docs/development/accessibility-and-localization/internationalization
Expand Down
30 changes: 15 additions & 15 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -27,20 +27,18 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "dev.adryanev.template"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
Expand Down Expand Up @@ -75,7 +73,7 @@ android {
}

flavorDimensions "default"
productFlavors {
productFlavors {
production {
dimension "default"
applicationIdSuffix ""
Expand Down Expand Up @@ -110,5 +108,7 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.20"
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}
15 changes: 1 addition & 14 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand All @@ -24,6 +11,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
30 changes: 22 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.2.1" apply false
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
}

include ":app"
Loading
Loading