Home > front end >  Is there a way to easily (and officialy?) integrate python, and more specifically matplotlib, with f
Is there a way to easily (and officialy?) integrate python, and more specifically matplotlib, with f

Time:01-19

I'm a scientist with a lot of python background, and I enjoy developping UI for little projects I develop, for fun. I have already built an android app with kivy, and I'm now studying dart and flutter. I find building the UI with flutter much easier than with kivy, but all the logic I had built for the app was in python, and it uses lots of packages (for magnetism calculations).

Is there a (easy/friendly) way to reuse the python scripts for the logic and/or matplotlib for outputting plots using flutter to design the UI?

Thanks in advance.

CodePudding user response:

You can use Flask as a wrapper for the Python functions and return the data in JSON format.

You can then consume the JSON data in Flutter by invoking the Flask endpoints (that in turn invoke Python functions) and present the data in the Flutter UI.

There are many articles on how to invoke HTTP services through Flutter and how to consume JSON data returned from said services into a Flutter Object.

Note: This will require a bit of set-up work and will require many more elements for production quality code, e.g., API Gateway, but for testing/learning purposes you can skip that and talk directly to the services you set-up in Flask.

  •  Tags:  
  • Related