-1
Future main() async {
  var target = await http.get(
    Uri.parse(myLink),
    headers: {"Accept": "application/json"},
  );
  String body = (utf8.decode(target.bodyBytes));
  myDecodedData = json.decode(body);
  runApp(myDecodedData);
}

now I want to display my code as json in a web pag

reza
  • 1,354
  • 1
  • 7
  • 25
ahmed
  • 1
  • 1
  • If you get data from API refer my answer [here](https://stackoverflow.com/a/68709502/13997210) or [here](https://stackoverflow.com/a/68533647/13997210) or [here](https://stackoverflow.com/a/68594656/13997210) hope it's helpful to you – Ravindra S. Patil Dec 21 '21 at 08:40
  • yes a got it from API but i dont want to use widget ,, only display my data as json on web@RavindraS.Patil – ahmed Dec 21 '21 at 08:45
  • If you display anything on web screen or mobile screen it not possible without using Widget you must used any widget – Ravindra S. Patil Dec 21 '21 at 08:52
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 25 '21 at 15:29

1 Answers1

0

If you want to display something, you need a widget. You cannot display something without any widget.

However, if you want the simplest way of just showing your JSON, you could encode it back to text and use the Text widget to show it all, the whole JSON in one widget.

That is technically still "a widget", but it's the least number of widgets you will have.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • i did that before but i want my data as json not as text – ahmed Dec 21 '21 at 08:51
  • If you encode something as json, *it is text*. The sentence "I want it as json, not as text" is meaningless. Please explain in detail what it is you want. – nvoigt Dec 21 '21 at 08:53
  • i want to call this web in postman so postman cant read this web cuz its a text thats why i want to display it as json – ahmed Dec 21 '21 at 11:27
  • You cannot "display it as json". It's a webpage. You already *have* an API that delivers JSON, perfect for postman, why not use it directly? – nvoigt Dec 21 '21 at 11:28
  • ill create a web server to get api throw this web server – ahmed Dec 21 '21 at 11:30
  • its all about security – ahmed Dec 21 '21 at 11:30
  • Well, Flutter is made for frontend UI applications. If you want to write a web *server* I'm sure it's possible in Dart, but Flutter might not be the best framework for it. You can try to start [here](https://dart.dev/tutorials/server/httpserver), but I would consider using a different language and framework that is actually made it it's purpose to build web APIs instead of (mis)using Flutter for it. – nvoigt Dec 21 '21 at 11:32