Thank you for your interest in contributing to Flet!
git clone https://github.com/flet-dev/flet
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
curl -sSL https://install.python-poetry.org | python3 -
cd sdk/python
To install all Flet dependencies and enable the project as editable package run:
poetry install
Create hello.py
file with a minimal Flet program:
import flet
from flet import Page, Text
def main(page: Page):
page.add(Text("Hello, world!"))
flet.app(target=main)
and then run it:
poetry run python hello.py
During the first run Flet Client (flet
) executable will be downloaded from Flet GitHub releases to a user temp directory and then started from there. The version of release to download from is taken from flet/version.py
file.
You should see a new native OS window opened with "Hello, world!" in it.
Pytest should be run with poetry run
:
poetry run pytest
The project uses Black formatting style. All .py
files in a PR must be black-formatted.
IDE-specific Black integration guides:
Enable "pylance" type checking in VS Code.
Open user settings, search by "pylance", scroll down to Python > Analysis: Type checking mode section. Enable basic mode.
Install isort
extension for imports formatting: https://marketplace.visualstudio.com/items?itemName=ms-python.isort
pre-commit is a dev dependency of Flet and is automatically installed by poetry install
.
To install the pre-commit hooks run: pre-commit install
.
Once installed, every time you commit, pre-commit will run the configured hooks against changed files.
When you run python3 hello.py, you might encounter an error like this:
FileNotFoundError: [Error 2] No such file or directory: '/var/folders/xm/cyv42vbs27gff3s39vy97rx00000gn/T/fletd-0.1.50/fletd'
To resolve the issue, just delete this folder ../T/fletd-0.1.50/fletd
. The folder is the one with the FileNotFound Error encountered earlier.
It should work now.
Add the following to ~/.zprofile
(or other profile scripts for your OS):
# Flet
export FLET_VIEW_PATH="$HOME/Projects/flet-dev/flet/client/build/macos/Build/Products/Release"
export FLET_WEB_PATH="$HOME/Projects/flet-dev/flet/client/build/web"
If you have Microsoft Edge installed and want to use it for debugging Flutter apps:
# Flutter
export CHROME_EXECUTABLE="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"