Type ‘String’ is not a subtype of type ‘int’ of ‘index’

DevOps

MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

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. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

Step 1: Check your Flutter project API URL

 body: new FutureBuilder<List>(
          future: authServices.getUserProfile(),
          builder: (context, snapshot) {
            if (snapshot.hasError) print(snapshot.error);
            print("yaha tak data");
            print(snapshot.data);
            if (snapshot.hasData) {
              // Only display the first item in the list
              var data = snapshot.data[0];
              // return Text(data.toString());
              return ItemList(list: snapshot.data);
            } else {
              return new Center(
                child: new CircularProgressIndicator(),
              );
            }
          },
        ));Code language: PHP (php)

Step 2: Check your Flutter project AuthServices page

Future<List> getUserProfile() async {
    final prefs = await SharedPreferences.getInstance();
    final key = 'token';
    final value = prefs.get(key);
    final pemail = 'email';
    final pvalue = prefs.get(pemail);
     print('dharmu ka data');
   print(pvalue);

    var url = Uri.parse(baseURL + 'get-user-profile/' + pvalue);

    http.Response response = await http.get(url, headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer $value'
    });

    print(response.statusCode);
    var getData = json.decode(response.body);
     print('dharmu ka data aa raha hai');
      print('yaha auth ka data');
    print(getData);
    return getData['data'];
  }Code language: PHP (php)

Step 3: Go to the base URL with the API

This is right Code Here


    public function getUserProfile(Request $request, $email){
        Log::info('In DcotorController->getAllDoctors... user data aa raha hau');
        $doctors =  User::where('email', $email)->get();
        $data = [
                     "status"=> "OK",
                     "data"=> $doctors,
                 ];
                 Log::info('Response ja raha h yaha se bhi ja raha hai');
        return response()->json($data, 200);
        Log::info('Response ja raha h aa raha haai dharmu ka user');
    }Code language: PHP (php)
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x