Skip to content

Conversation

@victorsanni
Copy link
Contributor

@victorsanni victorsanni commented Feb 4, 2025

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Feb 4, 2025
@victorsanni victorsanni marked this pull request as ready for review February 20, 2025 21:36
@victorsanni victorsanni requested a review from Piinks February 21, 2025 20:14
/// To use this mixin, implement the [buildHeader] and [buildBody] methods to
/// provide the header and body widgets. The [buildExpansible] method can be
/// overridden to further customize the layout of the widget.
mixin ExpansibleStateMixin<S extends StatefulWidget> on TickerProviderStateMixin<S> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest instead of defining mixin in widget layer, consider create a Base class and expose hook in constructor for material and cupertino to customize this base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a similar example to draw from? As a POC

Copy link
Contributor

@chunhtai chunhtai Feb 21, 2025

Choose a reason for hiding this comment

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

editableText, RawMenuAnchor, or any class that start with Raw* or *Base

Copy link
Contributor

@chunhtai chunhtai Feb 21, 2025

Choose a reason for hiding this comment

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

one thing to keep in mind as I saw some example here as well, if a property in this class needs to be used by the material class, they should probably be owned from the material and pass into this class, the animationController is one example.

Also, base class should not attempt to do fallback, anything that needs a fall back should be a required pass in parameter (otherwise, you may face an issue where you attempt to do the fallback in multiple layer of the widgets)and the fallback logic should be in the material or cupertino class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

editableText, RawMenuAnchor, or any class that start with Raw* or *Base

RawAutocomplete does something similar with fieldViewBuilder and optionsViewBuilder, I see. So maybe we could have a headerBuilder and a bodyBuilder or something like that.

/// The controller's [expand] and [collapse] methods cause the
/// the expansible widget to rebuild, so they may not be called from
/// a build method.
class ExpansibleController<S extends StatefulWidget> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a base class can also eliminate the S

Curve get expansionCurve;

/// True if the widget is initially expanded, and false otherwise.
bool get initiallyExpanded;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this meant to be control by a controller, do we need this field? if someone care about the initial state, they should probably provide their own controller, otherwise we can default to collapsed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's trivial to call controller.expand in initState and that would handle this behavior anyways. But I think the controller is just an add-on, not all cases might want to use it. This is just for convenience in the case where the user cares about the initial state but doesn't use a controller or want to worry about controller logic.

Copy link
Contributor

@chunhtai chunhtai Feb 21, 2025

Choose a reason for hiding this comment

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

oh I meant we set the initial state by this field, but uses controller to toggle since a bit weird to me. We should either move the state to controller similar to what TextEditingController does, or move the toggle method to the ExpansionTileState and remove the controller. For the latter, customer will then use globalkey.currentState.expand to control the state

but I see this is existing behavior before the refactor, so probably can be done in different pr

@victorsanni victorsanni marked this pull request as draft March 12, 2025 22:37
@victorsanni victorsanni deleted the raw-expansion-tile branch July 1, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codeshare between ExpansionTile and its Cupertino variant

4 participants