createJSONFile method
- String fileName,
- dynamic response
Creates a JSON file fileName
and stores it in a local directory.
Does nothing if fetch cannot establish a connection
Implementation
Future createJSONFile(String fileName, http.Response response) async {
if (response.statusCode == 200) {
final directory = await getApplicationDocumentsDirectory();
final file = File('${directory.path}/$fileName.json');
await file.writeAsString(response.body);
}
}