0

I want to open seperate screen for my each list items

want this

code

     ...index["data"]
                        .map(
                          (index) => Padding(
                            padding: EdgeInsets.only(top: 2.h),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                GestureDetector(
                                  onTap: () {
                                    index["onTap"];
                                  },
                                  child: Text(
                                    index["type"],
                                    style: TextStyle(
                                        color: AppColors.primaryColor,
                                        fontSize: 13.sp,
                                        fontWeight: FontWeight.w700),
                                  ),
                                ),
                                SizedBox(
                                  height: 0.3.h,
                                ),
                                Text(
                                  index["details"],
                                  style: TextStyle(
                                    fontSize: 9.3.sp,
                                    color: AppColors.blackColor
                                        .withOpacity(0.8),
                                    fontWeight: FontWeight.w600,
                                  ),
                                ),
                              ],
                            ),
                          ),
                        )
                        .toList(),

List for navigation function and other items list is in format of List

and use ...list.map => .toList

my list

**List list = [ { "category": 'Your posts', "data": [ { "type": 'Pending posts', "details": 'fdh fghfg nlfro refglrhgre tghrig ffr gk', "onTap": () { print('++++++++++++'); //// function for navigation to screen 1 }, }, ]; **

1
  • You should really use proper models for this, not a dynamic map. Every time you use dynamic explicitely or implicitely by omitting the actual type, you cheat yourself out of compiler support you could have had. Your compiler would have told you where the problem was, if it had known what you were doing. You hid your intent from your compiler and you compiler was unable to help you. Don't make programming harder than it already is.
    – nvoigt
    Jun 2, 2022 at 6:44

1 Answer 1

2

Could you please try directly assigning method to onTap like this...

onTap: index['onTap']

it will directly replace onTap function coming from list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.