I need someone help -
I found this error many times, I am also try with many types but nothing work.
this is my API link --
http://103.137.75.74:82/new_connection/?search=test
This is my controller ---
import 'package:dio/dio.dart';
import 'package:get/get.dart';
class ConnectionController extends GetxController {
final _dio = Dio();
final connectionList = [].obs;
getconnectionList() async {
try {
final res = await _dio
.get('http://support.nbox.live:82/new_connection/?search=test');
if (res.statusCode == 200) {
print('-------------------------');
print('Api data length : ${res.data.length}');
print('-------------------------');
print('Get data length : ${connectionList.length}');
print('-------------------------');
connectionList.addAll(res.data);
}
} catch (e) {
print(e);
}
}
}
I need someone's help. Any senior developer helps me, please.
CodePudding user response:
Change this :
final connectionList = [].obs;
to this
final RxList<Map<String, dynamic>> connectionList = [].obs;
CodePudding user response:
If you are looking the solution to this problem, this one works.
Precise the datatype that your list contains like so:
final RxList<Map<String, dynamic>> connectionList = []<Map<String, dynamic>>.obs;
