Skip to content

🚀 Feature: context.res.send(); , 1st parameter accepts only a String . #50

Description

@Shiba-Kar

🔖 Feature description

Allow context.res.send(); 1st parameter accepts String and bytes so as to send Uint8List as data.
I am trying to send Uint8List as the 1st parameter getting the below error

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");
}
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>

🎤 Pitch

Allow to accept 1st parameter as dynamic

OLD

context.res.send(<String>, <int>, Map<String,dynamic>);

NEW

context.res.send(<dynamic>, <int>, Map<String,dynamic>);

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions