DEV Community

Maxim Saplin
Maxim Saplin

Posted on • Edited on

Flet is "The fastest way to build Flutter apps in Python" - it's not :(

"The fastest way to build Flutter apps in Python" is the title of Flet's web page. As someone coming from the Flutter world reading the line I draw an ideal picture of "swapping Dart language for Python and magically having the whole power of Flutter framework at the tips of your fingers".

Not Flutter

Upon inspection of the sample code written in Flet, I see no Flutter:

Image description

  • There are no widgets - the cornerstone of Flutter (immutable UI configuration). There's no such concept.
  • It has its own library of controls, you can't use the standard Flutter UI library
  • It is imperative, i.e. you explicitly create UI elements (aka controls) and mutate their state
  • UI updates are explicit and require page.update() call

Philosophically, the above snippet of Flet code represents anti-Flutter, the way of doing UI that Flutter was created to move away from. Here's the quote from Flutter architectural overview:

Flutter is a reactive, declarative UI framework, in which the developer provides a mapping from application state to interface state, and the framework takes on the task of updating the interface at runtime when the application state changes. This model is inspired by work that came from Facebook for their own React framework, which includes a rethinking of many traditional design principles.

While Flutter is used to power Flet behind the scenes, it is hidden deep. None of the features Flutter is famous and valued for can't be seen in Flet.

Not the fastest

Flutter is known for its reach ecosystem and availability of many high-quality libraries. There're over 38000 packages at pub.dev and none of those e are available to build UI in Flet.

Besides none of the Flutter-specific materials (blogs, StackOverflow questions, docs) can be applied here.

As long as you're not building a counter app there're few readily available modules OR docs that can make you faster.

What Flet actually is

In a wide sense, Felt is a cross-platform, server-driven, imperative UI framework for Python. It uses Flutter behind the scenes to build and package UI clients that communicate with the Python backend and render the UI. It keeps developers away from Flutter clients, they are ready-made and not intended to be changed.

In the context of the Flutter ecosystem, Flet is a package published at pud.dev that allows you to put a widget in your app and render UI generated by Flet's Python server:



Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flet Flutter Demo',
home: FletApp(pageUrl: "http://localhost:8550"),
);
}

Enter fullscreen mode Exit fullscreen mode




Is it bad?

No, it's not! The creators of the package did a huge job and presented a UI framework that lets anyone who knows Python jump onto developing cross-platform apps for Windows, Linux, macOS, Android, iOS, and the Web. There's no need to learn a new programming language. No need to learn complicated paradigms with state management, reactive UI whatever.

However, the communication from Flet's team can be confusing and misleading.

If someone has Flutter experience, is building an app, and comes to Flet seeking to integrate Python - the expectations will likely be inflated and wrong. I don't think this person can be convinced to forgo all the goods of Flutter and switch to a completely new UI framework which is light years behind. There're better ways to couple Flutter and Python.

If someone has Python knowledge but no UI development experience, is building a simple UI for any of the platforms, and wants to start fast - Flet can be the right choice.

Yet if you're building UI that will last, Flet's imperative UI (reminding of the old good days of C++/MFC, Delphi, and ASP.NET Web Forms) can be an issue. There's a reason why we have plenty of modern UI frameworks that don't do that. With a sophisticated UI state, you will be creating a lot of hard-to-maintain and buggy code. Keeping in your head all the places that need to be manually updated (every time you have a new requirement) won't be easy. Learning a capable UI framework that promotes good practices might be a better option for building complicated UI driven apps.

Top comments (10)

Collapse
 
mrcsabatoth profile image
Csaba Toth

Flet reminds me of streamlit and gradio style programs which is a new way and as someone who wrote multiple apps in all (Flutter, streamlit, and gradio - not flet yet) of them you can sketch and prototype an app faster than Flutter. But I see your point as well.

Collapse
 
maximsaplin profile image
Maxim Saplin • Edited

A small remark.. As someone who started programming in 2000s, I see Streamlit and Flet resembling the way UI apps were built with technologies such as C++ MFC, Delphi, Windows Forms, ASP and ASP.NET Web Forms :)

I have observed this spiral making its turn, 2000s everyone was into "Visual Programming", RAD (Rapid Application Development). 2010s were all-in on sophisticated state management and patterns (Rx, MVC, MVP etc.), tools like Streamlit would be perceived as bad manners. And here we go, 2020s had all those 2000s princinples re-introduced in a slightly different way :)

Collapse
 
mrcsabatoth profile image
Csaba Toth

I was around as well. During those years CSS, HTML and JavaScript were separated so potentially a designer could come in and only tweak the CSS to tune the UI. Remember Microsoft WebMatrix for example?

Then react came along which puked everything into one tsx file. Bleh. The whole separation principle out the window, and IDE linters had a hard time in the beginning to analyze the puke.

Collapse
 
arseytech profile image
Arsey Kun

not the fastest but fun to build applications that solve a real world, just needs imagination. any way i'm starting a blog on flet with a simple calculator app, i speak python and would love to share me knowledge
even though flet is not the fastest, i believe it was designed for python devs to use rather switching to a new a language, flet is also etendable meaning it can be extended with flutter plugins for scalabality.
not here to criticize it's just like that❤
peace out

Collapse
 
mj_pender_c1e5a9ea8760883 profile image
MJ Pender

Hi Arsey,
Yes there are quite a few Flet how to tutorials on YouTube now. I recommend the first series by SmartGuruCool . He created a set of 12 tutorials building on each lesson -- free and well done. He was the first. Now there are quite a few -- just go to You tube and put Flet into the search.
I really like Flet for the web apps that I am creating for small business customers. I don't have the talent or time for the Flutter learning curve. mj

Collapse
 
arseytech profile image
Arsey Kun

Thanks, will try it but,was also planning content creation on youtube for python and web development content,
The channel is smartguru right, will check it out soon

Collapse
 
snoop911 profile image
snoop911

The state management advantage of flutter seems to be complicated by the fact that there are so many options , and strategies to implement. Fred Grott has a good write up on this.

Regarding Flet, any idea if it would work with any flutter package.. like arkit or ar_flutter_plugin? If one could quickly build an ar app in Python/flutter I'm sold!

Btw, any plans to make flutter how to videos?

Collapse
 
maximsaplin profile image
Maxim Saplin

Building quickly and maintaining relaibly are two different thing. And Flutter seems to be in a perfect sweet spot. I had some experience building an app with Streamlit last year, and I can see an analogy with Flet - similar imperative updates of the UI, easy to sketch and run a PoC. Yet I would never be building any serious UI with Streamlit, it's horrible the moment you step away from what the framework has to offer... Yet Streamlit authors manage the expectations right, saying it is a tool for PoC

Collapse
 
arseytech profile image
Arsey Kun

True tho, i myself wouldn't recommend using flet for serious or larger projects but minimal UIs can be a great choice.

FACT ABOUT ME: flet helped learn how Flutter works and built a simple ui project in flutter without even learning.
The code is not well organize u can find it on my github here check it out and see.

This was my greatest achievement in my history of programming
flutter devs please provide insights and feedback and criticism.

In conclusion, flet is a fun library to play and work with,
but requires some UI knowledge to work with.
Nice right!

Collapse
 
avisheks profile image
Avishek sharma

Kivy is more systematic for Android apps, provided the user doesn't know anything about UI design or is completely new to the app making field.