Thanks to visit codestin.com
Credit goes to github.com

Skip to content

module 'flet' has no attribute 'alignment'. #5292

@tct123

Description

@tct123

Duplicate Check

Describe the bug

@FeodorFitsner Hello. I am using flet version 0.28.1. I started a new project with this version and I used the default code.
It returned the following error:

(flet:19828): Atk-CRITICAL **: 01:15:05.719: atk_socket_embed: assertion 'plug_id != NULL' failed
Unhandled error processing page session : Traceback (most recent call last):
  File "/home/anonym/.local/lib/python3.13/site-packages/flet/app.py", line 247, in on_session_created
    await asyncio.get_running_loop().run_in_executor(
        executor, session_handler, page
    )
  File "/usr/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/anonym/flettwentyeight/src/main.py", line 19, in main
    alignment=ft.alignment.center,
              ^^^^^^^^^^^^
AttributeError: module 'flet' has no attribute 'alignment'. Did you mean: 'Alignment'?

embedder.cc (2519): 'FlutterEngineRemoveView' returned 'kInvalidArguments'. Remove view info was invalid. The implicit view cannot be removed.

** (flet:19828): WARNING **: 01:15:10.995: Attempted to set message handler on an FlBinaryMessenger without an engine

** (flet:19828): WARNING **: 01:15:10.995: Attempted to set message handler on an FlBinaryMessenger without an engine

python code:

import flet as ft


def main(page: ft.Page):
    counter = ft.Text("0", size=50, data=0)

    def increment_click(e):
        counter.data += 1
        counter.value = str(counter.data)
        counter.update()

    page.floating_action_button = ft.FloatingActionButton(
        icon=ft.Icons.ADD, on_click=increment_click
    )
    page.add(
        ft.SafeArea(
            ft.Container(
                counter,
                alignment=ft.alignment.center,
            ),
            expand=True,
        )
    )


ft.app(main)

Code sample

Code
import flet as ft


def main(page: ft.Page):
    counter = ft.Text("0", size=50, data=0)

    def increment_click(e):
        counter.data += 1
        counter.value = str(counter.data)
        counter.update()

    page.floating_action_button = ft.FloatingActionButton(
        icon=ft.Icons.ADD, on_click=increment_click
    )
    page.add(
        ft.SafeArea(
            ft.Container(
                counter,
                alignment=ft.alignment.center,
            ),
            expand=True,
        )
    )


ft.app(main)

To reproduce

flet create newapp
cd newapp
flet run

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

Linux

Operating system details

Fedora 42

Flet version

0.28.1

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions