Skip to content

no object passed when an event occur in any flutter widget  #50634

@lionviskame

Description

@lionviskame

i have noticed that there is no object (widget in current state) passed when an event occur in any flutter widget .
if we take this example

class _FavoriteWidgetState extends State<FavoriteWidget> {
  // ···
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Container(
          padding: EdgeInsets.all(0),
          child: IconButton(
            icon: (_isFavorited ? Icon(Icons.star) : Icon(Icons.star_border)),
            color: Colors.red[500],
           onPressed: (){//some work}
          ),
        ),
        SizedBox(
          width: 18,
          child: Container(
            child: Text('$_favoriteCount'),
          ),
        ),
      ],
    );
  }
}

we notice "onPressed" within "IconButton" widget doesn't have a function signature that allow the object(widget in the current state) to be passed as argument like java(native android app) or c#(winforms) did , that would be hell for dynamic widget generation or some generic logic. it would be very nice if you take this as a new feature or fix . thx

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions