setup method
dynamic
setup(
- String serverUri
)
Implementation
setup(String serverUri) async {
serverUri = serverUri.trim();
if (!serverUri.startsWith('http')) serverUri = 'https://$serverUri';
if (serverUri.endsWith('/')) {
serverUri = serverUri.substring(0, serverUri.lastIndexOf('/'));
}
final response =
await dio.get('$serverUri/api/account/ping', options: Options());
if (!(response.data as Map).containsKey('bizDoc')) throw '';
final preferences = await SharedPreferences.getInstance();
preferences.setString('baseUri', serverUri);
dio.options.baseUrl = '$serverUri/api';
}