Код: Выделить всё
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:http/http.dart' as http;
import 'package:test/paymentmodel.dart';
class ApiService {
final Dio dio;
ApiService(this.dio);
Future getall() async {
String username = '11191082';
String password = 'dayfreetrial';
String basicAuth =
'Basic ' + base64Encode(utf8.encode('$username:$password'));
print(basicAuth);
var response = await dio.get(
'http://example-001-site1.atempurl.com/api/SalesInvoice/GetAllPayments',
options: Options(headers: {
'Authorization':
basicAuth,
}));
List datat = jsonDecode(response.data);
List storesList = [];
for (int i = 0; i < datat.length; i++) {
storesList.add(
PaymentMethodModel.fromJson(datat[i]),
);
}
return storesList;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... in-dio-pac