Skip to content

PoC on type definition change#43

Open
aydinguven-leancode wants to merge 2 commits into
refactor/cubit-to-notifier-migrationfrom
feature/field_controller_type_def
Open

PoC on type definition change#43
aydinguven-leancode wants to merge 2 commits into
refactor/cubit-to-notifier-migrationfrom
feature/field_controller_type_def

Conversation

@aydinguven-leancode

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates AdvancedFieldBuilder to preserve and pass the concrete controller subtype into the builder callback (instead of passing AdvancedFieldState<T, E>), and migrates internal examples/tests to the new API.

Changes:

  • Refactors AdvancedFieldBuilder to be generic on controller type C and rebuild via ListenableBuilder.
  • Updates widget examples to use AdvancedFieldBuilder and read state via field.value.
  • Updates the AdvancedFieldBuilder widget test to the new builder signature.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/src/field/field_builder_test.dart Migrates widget test to new AdvancedFieldBuilder<C> signature and state access via field.value.
lib/src/field/builder/advanced_field_builder.dart Changes AdvancedFieldBuilder API to pass the controller subtype into the builder; swaps to ListenableBuilder.
example/lib/widgets/form_text_field.dart Migrates example text fields from ValueListenableBuilder to AdvancedFieldBuilder.
example/lib/widgets/form_switch_field.dart Migrates example switch field from ValueListenableBuilder to AdvancedFieldBuilder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +15
/// Builder signature for [AdvancedFieldBuilder]. Receives the field controller
/// itself (with its concrete subtype preserved) so subclass-specific API like
/// `textController` or `focusNode` is reachable without a cast or context lookup.
typedef AdvancedFieldWidgetBuilder<
C extends AdvancedFieldController<Object?, Object>>
= Widget Function(BuildContext context, C field, Widget? child);

/// Rebuilds whenever [field] notifies. Hands the controller back to [builder]
/// with its exact subclass type, so subclass-specific methods are available at
/// the call site without a closure capture or cast.
class AdvancedFieldBuilder<C extends AdvancedFieldController<Object?, Object>>
extends StatelessWidget {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants