[PR #4724] [MERGED] feat: use result instead of either #6407

Closed
opened 2026-03-23 22:23:05 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/4724
Author: @LucasXu0
Created: 2/24/2024
Status: Merged
Merged: 2/24/2024
Merged by: @LucasXu0

Base: mainHead: use_result_instead_of_either


📝 Commits (2)

  • 596c741 feat: use result instead of either
  • 39f5d6c chore: remove dartz

📊 Changes

190 files changed (+1816 additions, -1530 deletions)

View changed files

📝 frontend/appflowy_flutter/integration_test/util/common_operations.dart (+1 -1)
📝 frontend/appflowy_flutter/lib/core/config/kv.dart (+10 -11)
📝 frontend/appflowy_flutter/lib/core/config/kv_keys.dart (+1 -1)
📝 frontend/appflowy_flutter/lib/core/helpers/helpers.dart (+0 -1)
frontend/appflowy_flutter/lib/core/helpers/url_validator.dart (+0 -21)
📝 frontend/appflowy_flutter/lib/core/notification/document_notification.dart (+2 -2)
📝 frontend/appflowy_flutter/lib/core/notification/folder_notification.dart (+5 -4)
📝 frontend/appflowy_flutter/lib/core/notification/grid_notification.dart (+6 -5)
📝 frontend/appflowy_flutter/lib/core/notification/notification_helper.dart (+5 -4)
📝 frontend/appflowy_flutter/lib/core/notification/user_notification.dart (+5 -4)
📝 frontend/appflowy_flutter/lib/date/date_service.dart (+17 -11)
📝 frontend/appflowy_flutter/lib/env/cloud_env.dart (+27 -37)
📝 frontend/appflowy_flutter/lib/mobile/application/user_profile/user_profile_bloc.dart (+1 -1)
📝 frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart (+2 -2)
📝 frontend/appflowy_flutter/lib/mobile/presentation/favorite/mobile_favorite_page.dart (+6 -4)
📝 frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_page.dart (+6 -4)
📝 frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_setting_page.dart (+9 -6)
📝 frontend/appflowy_flutter/lib/mobile/presentation/setting/user_session_setting_group.dart (+4 -6)
📝 frontend/appflowy_flutter/lib/plugins/database/application/calculations/calculations_listener.dart (+5 -5)
📝 frontend/appflowy_flutter/lib/plugins/database/application/calculations/calculations_service.dart (+4 -2)

...and 80 more files

📄 Description

Feature Preview

In our Rust implementation, we use the Result type to handle errors. Due to historical reasons, we used the Either type from the dartz package for managing both success and error cases in our Flutter application.

However, there is a notable convention difference between Either and Result: Either uses its Right side to represent success, and Result uses its Left side for this purpose. To keep consistency in behavior across our implementations, we have implemented the Result type in Flutter to align with this convention.

  • added FlowyResult type
  • used FlowyResult instead of Either
  • used ? syntax instead of Option
  • removed dartz package

PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/4724 **Author:** [@LucasXu0](https://github.com/LucasXu0) **Created:** 2/24/2024 **Status:** ✅ Merged **Merged:** 2/24/2024 **Merged by:** [@LucasXu0](https://github.com/LucasXu0) **Base:** `main` ← **Head:** `use_result_instead_of_either` --- ### 📝 Commits (2) - [`596c741`](https://github.com/AppFlowy-IO/AppFlowy/commit/596c741e57b3af3a3c46b35776b7c828957efddd) feat: use result instead of either - [`39f5d6c`](https://github.com/AppFlowy-IO/AppFlowy/commit/39f5d6cb652b351bad7c32f235b259ad3dc0e665) chore: remove dartz ### 📊 Changes **190 files changed** (+1816 additions, -1530 deletions) <details> <summary>View changed files</summary> 📝 `frontend/appflowy_flutter/integration_test/util/common_operations.dart` (+1 -1) 📝 `frontend/appflowy_flutter/lib/core/config/kv.dart` (+10 -11) 📝 `frontend/appflowy_flutter/lib/core/config/kv_keys.dart` (+1 -1) 📝 `frontend/appflowy_flutter/lib/core/helpers/helpers.dart` (+0 -1) ➖ `frontend/appflowy_flutter/lib/core/helpers/url_validator.dart` (+0 -21) 📝 `frontend/appflowy_flutter/lib/core/notification/document_notification.dart` (+2 -2) 📝 `frontend/appflowy_flutter/lib/core/notification/folder_notification.dart` (+5 -4) 📝 `frontend/appflowy_flutter/lib/core/notification/grid_notification.dart` (+6 -5) 📝 `frontend/appflowy_flutter/lib/core/notification/notification_helper.dart` (+5 -4) 📝 `frontend/appflowy_flutter/lib/core/notification/user_notification.dart` (+5 -4) 📝 `frontend/appflowy_flutter/lib/date/date_service.dart` (+17 -11) 📝 `frontend/appflowy_flutter/lib/env/cloud_env.dart` (+27 -37) 📝 `frontend/appflowy_flutter/lib/mobile/application/user_profile/user_profile_bloc.dart` (+1 -1) 📝 `frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart` (+2 -2) 📝 `frontend/appflowy_flutter/lib/mobile/presentation/favorite/mobile_favorite_page.dart` (+6 -4) 📝 `frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_page.dart` (+6 -4) 📝 `frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_setting_page.dart` (+9 -6) 📝 `frontend/appflowy_flutter/lib/mobile/presentation/setting/user_session_setting_group.dart` (+4 -6) 📝 `frontend/appflowy_flutter/lib/plugins/database/application/calculations/calculations_listener.dart` (+5 -5) 📝 `frontend/appflowy_flutter/lib/plugins/database/application/calculations/calculations_service.dart` (+4 -2) _...and 80 more files_ </details> ### 📄 Description <!--- Thank you for submitting a pull request to AppFlowy. The team will dedicate their best efforts to reviewing and approving your pull request. If you have any questions about the project or feedback for us, please join our [Discord](https://discord.gg/wdjWUXXhtw). --> <!--- If your pull request adds a new feature, please drag and drop a video into this section to showcase what you've done! If not, you may delete this section. --> ### Feature Preview In our Rust implementation, we use the `Result` type to handle errors. Due to historical reasons, we used the `Either` type from the dartz package for managing both success and error cases in our Flutter application. However, there is a notable convention difference between Either and Result: `Either` uses its Right side to represent success, and `Result` uses its Left side for this purpose. To keep consistency in behavior across our implementations, we have implemented the `Result` type in Flutter to align with this convention. - added FlowyResult type - used FlowyResult instead of Either - used ? syntax instead of Option - removed dartz package <!--- List at least one issue here that this PR addresses. If it fixes the issue, please use the [fixes](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests) keyword to close the issue. For example: fixes https://github.com/AppFlowy-IO/AppFlowy/pull/2106 --> --- <!--- Before you mark this PR ready for review, run through this checklist! --> #### PR Checklist - [x] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [ ] I've listed at least one issue that this PR fixes in the description above. - [ ] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [ ] All existing tests are passing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 22:23:05 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#6407
No description provided.