I am looking for the best way to get curls in Dart. For example, how to get google.com web content and display it as an example.
I found that I can call it a shell, as shown here , however this does not seem to be the ideal approach:
import 'dart:io'; main() { var f = new File(new Options().executable); Process.start('curl', ['--dump-header', '/tmp/temp_dir1_M8KQFW/curl-headers', '--cacert', '/Users/ager/dart/dart/third_party/curl/ca-certificates.crt', '--request', 'POST', '--data-binary', '@-', '--header', 'accept: ', '--header', 'user-agent: ' , '--header', 'authorization: Bearer access token', '--header', 'content-type: multipart/form-data', '--header', 'content-transfer-encoding: binary', '--header', 'content-length: ${f.lengthSync()}', 'http://localhost:9000/upload']).then((p) { f.openInputStream().pipe(p.stdin); p.stdout.pipe(stdout); p.stderr.pipe(stderr); p.onExit = (e) => print(e); }); }
I also looked at the API and did not find anything to help me here.
source share