sdk-for-dart icon indicating copy to clipboard operation
sdk-for-dart copied to clipboard

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

Open Shiba-Kar opened this issue 2 years ago • 1 comments

🔖 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?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Shiba-Kar avatar Nov 23 '23 19:11 Shiba-Kar

@Meldiron I think this is related to Functions Runtimes and not SDK can you please check.

lohanidamodar avatar Jan 03 '24 06:01 lohanidamodar