#return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});

11 messages · Page 1 of 1 (latest)

tropic bough
#

type 'Uint8List' is not a subtype of type 'String' of 'body'
#0 main (package:generate_pdf/main.dart)
<asynchronous suspension>
#1 Future.any.onValue (dart:async/future.dart:615)
<asynchronous suspension>

Future<dynamic> main(final context) async {
  final pdf = PDF();
  final order = FakeOrder();
  var fakeOrder = order.createFakeOrder();
  context.log(fakeOrder.toJson().toString());
  final Uint8List? bytes = await pdf.createAndSave(fakeOrder);

  if (bytes != null) {
    context.log('PDF created.');
    context.log(bytes);

    return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});
  }

  return context.error("Someting gone wrong");
}

limber pawn
tropic bough
#

this line return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});

limber pawn
#

Can you create a feature request for supporting non-strings?

tropic bough
#

I have created a pull-request

frail moth
# tropic bough I have created a pull-request

Thanks for contributing ✨ Could you please also implement a test for it?

You will need to add a new case here: https://github.com/Shiba-Kar/open-runtimes/blob/main/tests/resources/functions/dart-3.0/lib/tests.dart#L118

In there, write a code that creates Uint8List, and sends it as response. To create it, you can read file, create it from string Hello World, or any other method that makes sense to you.

Next, you will need to add execution to a test script, which can be seen here: https://github.com/Shiba-Kar/open-runtimes/blob/main/tests/Base.php#L377-L388

In there you should expect specific response. Maybe bytes? Maybe multibytes? Maybe value after utf8 encoding? Not sure, do whatever feels natural to you and I will take a look during PR review.

Doing this will make tests in all other runtimes fail, but you can ignore that if you want to only focus on Dart. I can do the remaning languages, or we could ask other contributors. Just make sure they pass in Dart 3.0

#

Please let me know if you are intereste in continuing this PR, and if you have any questions 🙏

tropic bough
#

yes I am actively working on it

tropic bough
#

cmd RUNTIME='dart-3.0' TEST_CLASS='Base' ENTRYPOINT='tests.dart' sh tests.sh