🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

How to get data in listview builder in flutter

flutter

I’m pretty new to using the REST API to get data and display it in a listview in Flutter.

API initializing 

 var productapi = new ProductAPI();
  @override
  void initState() {
    super.initState();
    productapi.gettripbooks().then((usersFromServer) {
      setState(() {
        users = usersFromServer;
        print(users);
        print('this is filter gettripbooks data');
           print(widget.data);
        var myfilteroperator =
            users.where((c) => c.customer_email == widget.data).toList();
        filteredUsers = myfilteroperator;
          print(filteredUsers);
      });
    });
  }

I created a list, filled that with dynamic data. Now I want all the data existing in listview

      child: Container(
        height: displayHeight(context) * 0.22,
        padding: const EdgeInsets.all(0),
        child: Column(
          children: [
            Expanded(
              child: ListView.builder(
                itemCount:
                filteredUsers.length > 95 ? 95 : filteredUsers.length,
                itemBuilder: (BuildContext context, int index) {
                  print('start date ');
                  print(filteredUsers[index].operator_emailid);
                  return filteredUsers[index].operator_emailid != null
                      ? InkWell(
                          child: Card(
                            child: Padding(
                              padding: const EdgeInsets.all(0.0),
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: <Widget>[
                                  ClipRRect(
                                    borderRadius: BorderRadius.circular(20),
                                    child: SingleChildScrollView(
                                      child: Image(
                                        image: NetworkImage(
                                          filteredUsers[index].poster != null
                                              ?    'https://www.holidaylandmark.com/storage/' +
                                                  filteredUsers[index].poster
                                              : "Not Found",
                                        ),
                                      ),
                                    ),
                                  ),
                                  Text(
                                    filteredUsers[index].TripHeading,
                                    textAlign: TextAlign.left,
                                    style: TextStyle(
                                      fontSize: displayWidth(context) * 0.042,
                                      fontFamily: "Roboto",
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                 
                                  Text(
                                    'Customer-Email:' +
                                        filteredUsers[index].customer_email,
                                    textAlign: TextAlign.left,
                                    style: TextStyle(
                                        fontSize: displayWidth(context) * 0.036,
                                        fontFamily: "Roboto",
                                        fontWeight: FontWeight.w500),
                                  ),

                                ],
                              ),
                            ),
                          ),

                        )
                      : Center();
                },
              ),
            ),
          ],
        ),
      ),

Output:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x