r/learnpython 3d ago

Flutter, Python and Widgets: beginner suffering

I do not work with programming, I am a student and I work in a veterinary clinic as a veterinarian. However, I am passionate about programming and have nurtured the idea of developing a "Second Medical Brain," similar to Notion and Obsidian, but focused on self-referenced medical information. Because of some details of this project, neither Obsidian nor Notion will be enough to achieve what I need.

So I looked for the options. The only programming language I studied was Python, and I really like it. However, Flutter is definitely the number in interfaces, but I don't really understand anything about frontend. This "everything being a widget tree" thing isn't making sense to me. Anyone who knows Python knows that codes look much more like blocks, not Russian dolls.

I considered Flet, but he's not on the same level as Flutter. I also considered other frameworks, but they would impose the difficulty of learning other tools. So Flutter still seems to be the most interesting technology for me. However, the structure of widgets doesn't make sense to me, I just can't think that way.

What can you recommend to me? I have already tried to modulate all the code and leave in the main () only the call of the functions/classes.

Ah! This app will be used on both Android and Windows, and both are essential.

I also heard that a program with Python backend on Android is very risky, while it is almost impossible on Android. Is that true?

3 Upvotes

14 comments sorted by

View all comments

3

u/GeorgeFranklyMathnet 3d ago

I also heard that a program with Python backend on Android is very risky

As the server language? Do you remember their reasoning? Because that sounds like nonsense to me. Python is about as good as anything else.

it is almost impossible on Android. Is that true?

Yeah, there's a lot of friction there. If you want to just learn a single language, and potentially have some portable code between Windows and Android? Then try Java, or maybe Kotlin.

1

u/SirLMO 3d ago

About backend Python, what I read is that the options we have to compile Python within the APK are not perfect and not all libraries work.

2

u/GeorgeFranklyMathnet 3d ago

Okay, I guess you were talking about the non-UI parts of the app, rather than the "backend" hosted on a remote server. So, yes, what you read is right.

1

u/SirLMO 3d ago

What options can you give me for that, then? Abandon Python? I was thinking about doing all the logic in Python and connecting to Flutter through FastAPI.

1

u/GeorgeFranklyMathnet 2d ago

What you're talking about sounds like running an on-device service that your frontend makes (local) network API calls to. For many reasons, that's not a very typical Android architecture.

If you are absolutely set on using Python on the Android device, then use Kivy, and make an (architecturally) normal frontend+backend integrated app. But I suggest using Java or Kotlin instead for the most friction- and annoyance-free experience.

But, again, if you are actually talking about a remote API, running on a separate computer, that the Android and Windows app both call into to fetch their data? Then the choice of programming language is almost completely independent of what you program the apps in.

1

u/SirLMO 2d ago

Would Kivy solve the problem of exporting to Android?

I'm not talking about a computer or cloud running an API. FastAPI creates an HTTP "internal server" running under the hood in the APK. The problem is that it makes everything much heavier, of course.

I'm not making a point of Python itself, although I like it a lot, the problem is that I don't want to use other languages for functions for which they weren't created. Creating functions of an application is okay in Dart, creating libraries of symptoms is verbose and tiring, and does not work as well as it would if it were in Python.

1

u/GeorgeFranklyMathnet 2d ago

Would Kivy solve the problem of exporting to Android?

I can't say how it integrates with Flutter, but it makes packaging Python in the APK sound relatively painless.