we are new to Flutter. We have a Google Sheet with data and would like to import that data to a Flutter App.
We tried this:
https://patilshreyas.github.io/Flutter2GoogleSheets-Demo/demo/
In the above link, you can find :
a. The test Google Sheet: https://docs.google.com/spreadsheets/d/1OOArrqjOqmD4GiJOWlluZ4woTMH_qaV6RKv4JXnT3Hk/edit#gid=0
b. the code from Git Hub:
https://github.com/PatilShreyas/Flutter2GoogleSheets-Demo
c. The Google AppScript code is:
`
function doGet(request){
// Open Google Sheet using ID
var sheet =
SpreadsheetApp.openById("1OOArrqjOqmD4GiJOWlluZ4woTMH_qaV6RKv4JXnT3Hk");
// Get all values in active sheet
var values = sheet.getActiveSheet().getDataRange().getValues();
var data = [];
// Iterate values in descending order
for (var i = values.length - 1; i >= 0; i--) {
// Get each row
var row = values[i];
// Create object
var feedback = {};
feedback['name'] = row[0];
feedback['email'] = row[1];
feedback['mobile_no'] = row[2];
feedback['feedback'] = row[3];
// Push each row object in data
data.push(feedback);
}
// Return result
return ContentService
.createTextOutput(JSON.stringify(data))
.setMimeType(ContentService.MimeType.JSON);
}
function doPost(request){
// Open Google Sheet using ID
var sheet = SpreadsheetApp.openById("1OOArrqjOqmD4GiJOWlluZ4woTMH_qaV6RKv4JXnT3Hk");
var result = {"status": "SUCCESS"};
try{
// Get all Parameters
var name = request.parameter.name;
var email = request.parameter.email;
var mobileNo = request.parameter.mobileNo;
var feedback = request.parameter.feedback;
// Append data on Google Sheet
var rowData = sheet.appendRow([name, email, mobileNo, feedback]);
}catch(exc){
// If error occurs, throw exception
result = {"status": "FAILED", "message": exc};
}
// Return result
return
ContentService.createTextOutput(JSON.stringify(result)).setMimeType(ContentService.MimeType.JSON);
}`
But, on running the code, we get the error:
E/flutter (23836): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SocketException: Failed host lookup: 'script.google.com' (OS Error: No address associated with hostname, errno = 7)
Would you please advise us on how we can resolve this error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…