Skip to content

Instantly share code, notes, and snippets.

@shonorio
Created July 13, 2025 09:46
Show Gist options
  • Select an option

  • Save shonorio/ec5a5a3573010325583fa957f9ed6736 to your computer and use it in GitHub Desktop.

Select an option

Save shonorio/ec5a5a3573010325583fa957f9ed6736 to your computer and use it in GitHub Desktop.
exemplo de task

Context:

You are working on a Flutter project using MobX for state management. Currently:

  • SignInController is the source of truth and exposes observable states and actions to SignInPage.
  • SignInPage binds directly to MobX's @observable, @computed, and @action annotations for its UI updates and logic.

Goal:

Migrate this flow to a Cubit-based architecture, using the Event-State pattern, to achieve:

  • A more explicit and testable state management approach.
  • Better separation of concerns between controller and UI.
  • A future-proof, Bloc-friendly codebase.

Requirements:

  • Replace MobX usage with Cubit.
  • Convert MobX actions (@action) to dispatched events that trigger state transitions.
  • SignInController becomes a Cubit that exposes void-returning methods triggering internal state updates.
  • State updates should follow Bloc Naming Conventions (SignInLoading, SignInSuccess, SignInFailure, etc.).
  • SignInPage listens to state changes and updates the UI accordingly.
  • No more direct state reads via @observable, use Cubit states instead.
  • Refactor helper methods in SignInPage into separate widgets where appropriate.

TODOs:

  • Analyze SignInController to identify MobX actions and map them to Cubit Events (Bloc Naming Conventions).
  • Draft a migration plan from MobX (@observable, @computed, @action) to Cubit Event-State architecture.
  • Create a dedicated sign_in_state.dart file with clear Cubit states.
  • Map controller methods: define which should be public and which should be private/internal.
  • Refactor public methods to follow Single Responsibility Principle.
  • Refactor SignInController into SignInCubit, moving all MobX logic to Cubit-compatible logic.
  • Refactor SignInPage to respond to Cubit state changes instead of MobX observables.
  • Deep-analyze SignInPage to map helper methods tied to UI updates.
  • Extract reusable helper methods in SignInPage into dedicated widgets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment