Search code examples
flutterfunctiondartflutter-widget

How to create a widget for map function in flutter with buildContext


I have this code

final users = snapshot.data!;
              return ListView(
                children: users.map(buildMember).toList(),
              );

I want to create a widget with buildConext

I tried

Widget buildMember(Member user, BuildContext context) => Card(
        child: ListTile()
);

But got this error: enter image description here


Solution

  • users.map((user) => buildMember(user, context)).toList(),