Code Monkey home page Code Monkey logo

flet_route's People

Contributors

saurabhwadekar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

craig8 isaffathir

flet_route's Issues

AppBar disappearing on route change

First of all, thank you very much for your work!

I used the example given in your documentation and simply added an AppBar (at the page level), in the first route "/" the appBar component is visible but when I change the route it disappears completely (until I switch back to /). Obviously the appbar is added on every view.

  return ft.View(
        "/",
        controls=[
            page.appbar,
            ft.Text("This Is Index View"),
            ft.ElevatedButton("Go Next View", on_click=lambda _: page.go("/second_view/")),
        ]
    )

How to deal with this? I don't know if this is a bug or my wrong approach.

More Documentation

Hey! Nice Package.
Please add more documentation in the README.
Detailed documentation for each parameter, each class and/or function.
It is very important for those using a package!

A Stack tool does not work well

Hello, I am working on a program whose background is an image, so to do what I want I must create a container and use the stack tool.
The problem is that when I run the program the view comes out with margins on the left, right and top; I already tried setting 'page.padding = 0' and it still doesn't work

image

Taking advantage of the opportunity, can you tell me how to make the container of another view have the height of my laptop, before I used page.window_height, but now since I am routing the program it no longer works

view_pop does cause duplicated view history without clear

Is there any document to use views without clear

view_pop, method of Routing, remove the last view of pages(page.views) and call go with top_view
It eventually call change_route and change_route append additional view to page.views
So there are duplicated view on page.views

Params don't work with static flet website

Hi, ai am building a static website with the use of flet_route, but i have stumbled upon issues as follow:
I am compiling with hash routing because when i try to use path routing i get error 404, page not found. This could also be because of flet_route, but thats not my main concern.

Standard Homepage with hash routing and flet_route:

image

When i try go to a page with a param:

image

When i am on page and clicked a button that adds a param:

image
image

Going to other page directly with using path routing:

image
This is why i am using hash routing at the moment, with path routing i can't directly go to url

Flet Static Website Url:

https://flet.dev/docs/guides/python/publishing-static-website/#web-renderer

Async

I don't know if async is supported, i have tryed but have not managed to get it to work. If its not supported will it be sometime in the future?

Unable to build apk when I include flet-route in requirements.txt

I get the following errors:

Flutter bootstrap directory:
/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/flet_flutter_build_TFx8OdAzb7
Additional Flutter dependencies:
{}
Creating Flutter bootstrap project...OK
Customizing app icons and splash images...OK
Generating app icons...
Run subprocess: ['/Users/temi/Desktop/desktop1//RayFlutter/flutter/bin/dart', 'run',
'flutter_launcher_icons']
Resolving dependencies in /private/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/flet_flutter_build_TFx8OdAzb7... (3.5s)
Got dependencies in /private/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/flet_flutter_build_TFx8OdAzb7.
Building package executable... (2.2s)
Built flutter_launcher_icons:flutter_launcher_icons.
════════════════════════════════════════════
FLUTTER LAUNCHER ICONS (v0.13.1)
════════════════════════════════════════════

• Creating default icons Android
• Overwriting the default Android launcher icon with a new icon
• Overwriting default iOS launcher icon with new icon
Creating Icons for Web... done
Creating Icons for Windows... done
Creating Icons for MacOS... done

✓ Successfully generated launcher icons
OK
Generating splash screens...
Run subprocess: ['/Users/temi/Desktop/desktop1//RayFlutter/flutter/bin/dart', 'run',
'flutter_native_splash:create']
Building package executable... (2.1s)
Built flutter_native_splash:create.
[Android] Creating default splash images
[Android] Creating dark mode splash images
[Android] Creating default android12splash images
[Android] Creating dark mode android12splash images
[Android] Updating launch background(s) with splash image path...
[Android] - android/app/src/main/res/drawable/launch_background.xml
[Android] - android/app/src/main/res/drawable-night/launch_background.xml
[Android] - android/app/src/main/res/drawable-v21/launch_background.xml
[Android] - android/app/src/main/res/drawable-night-v21/launch_background.xml
[Android] Updating styles...
[Android] - android/app/src/main/res/values-v31/styles.xml
[Android] No android/app/src/main/res/values-v31/styles.xml found in your Android project
[Android] Creating android/app/src/main/res/values-v31/styles.xml and adding it to your Android project
[Android] - android/app/src/main/res/values-night-v31/styles.xml
[Android] No android/app/src/main/res/values-night-v31/styles.xml found in your Android project
[Android] Creating android/app/src/main/res/values-night-v31/styles.xml and adding it to your Android project
[Android] - android/app/src/main/res/values/styles.xml
[Android] - android/app/src/main/res/values-night/styles.xml
[iOS] Creating images
[iOS] Creating dark mode images
[iOS] Updating ios/Runner/Info.plist for status bar hidden/visible
[Web] Creating images
[Web] Creating images
[Web] Creating background images
[Web] Creating CSS
[Web] Updating index.html
╔════════════════════════════════════════════════════════════════════════════╗
║ NEED A GREAT FLUTTER DEVELOPER? ║
╠════════════════════════════════════════════════════════════════════════════╣
║ ║
║ I am available! Find me at https://www.linkedin.com/in/hansonjon/
║ ║
╚════════════════════════════════════════════════════════════════════════════╝

✅ Native splash complete.
Now go finish building something awesome! 💪 You rock! 🤘🤩
Like the package? Please give it a 👍 here: https://pub.dev/packages/flutter_native_splash

OK
Packaging Python app...
Run subprocess: ['/Users/temi/Desktop/desktop1//RayFlutter/flutter/bin/dart', 'run',
'serious_python:main', 'package', '/Users/temi/Desktop/RayFlet/cool', '--mobile', '--platform',
'mobile', '--dep-mappings', 'flet=flet-embed', '--req-deps', 'flet-embed', '--exclude', 'build']
Building package executable... (1.1s)
Built serious_python:main.
Running package command
Creating asset directory: /private/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/flet_flutter_build_TFx8OdAzb7/app
Copying Python app from /Users/temi/Desktop/RayFlet/cool to /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/serious_python_tempEU0Z6h
Configured mobile platform with sitecustomize.py at /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/serious_python_sitecustomizeszSeYa/sitecustomize.py
Installing dependencies [flet-embed, flet-route, requests] with pip command to /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/serious_python_tempEU0Z6h/pypackages
Extracting Python distributive from /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/cpython-3.11.6+20231002-x86_64-apple-darwin-install_only.tar.gz to /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/hostpython3.11_KIgCmK
/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/hostpython3.11_KIgCmK/python/lib/python3.11/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [60 lines of output]
Collecting maturin<2,>=0.14.16
Using cached maturin-1.5.1.tar.gz (181 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: maturin
Building wheel for maturin (pyproject.toml): started
Building wheel for maturin (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error

    × Building wheel for maturin (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [35 lines of output]
        /private/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/pip-build-env-38px953a/overlay/lib/python3.11/site-packages/setuptools/config/_apply_pyprojecttoml.py:83: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (dependencies)
          corresp(dist, value, root_dir)
        running bdist_wheel
        running build
        running build_py
        creating build
        creating build/lib.macosx-10.9-x86_64-cpython-311
        creating build/lib.macosx-10.9-x86_64-cpython-311/maturin
        copying maturin/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-311/maturin
        copying maturin/import_hook.py -> build/lib.macosx-10.9-x86_64-cpython-311/maturin
        copying maturin/__main__.py -> build/lib.macosx-10.9-x86_64-cpython-311/maturin
        running egg_info
        creating maturin.egg-info
        writing maturin.egg-info/PKG-INFO
        writing dependency_links to maturin.egg-info/dependency_links.txt
        writing requirements to maturin.egg-info/requires.txt
        writing top-level names to maturin.egg-info/top_level.txt
        writing manifest file 'maturin.egg-info/SOURCES.txt'
        reading manifest file 'maturin.egg-info/SOURCES.txt'
        reading manifest template 'MANIFEST.in'
        warning: no files found matching '*.json' under directory 'src/python_interpreter'
        writing manifest file 'maturin.egg-info/SOURCES.txt'
        running build_ext
        running build_rust
        error: can't find Rust compiler
  
        If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.
  
        To update pip, run:
  
            pip install --upgrade pip
  
        and then retry package installation.
  
        If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
        [end of output]
  
    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for maturin
  Failed to build maturin
  ERROR: Could not build wheels for maturin, which is required to install pyproject.toml-based projects
  
  [notice] A new release of pip is available: 23.2.1 -> 24.0
  [notice] To update, run: /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/hostpython3.11_KIgCmK/python/bin/python3 -m pip install --upgrade pip
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: /var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/hostpython3.11_KIgCmK/python/bin/python3 -m pip install --upgrade pip
Deleting Flutter bootstrap directory
/var/folders/0z/j9wwzxsj2k3fz7gft1ws_kkc0000gn/T/flet_flutter_build_TFx8OdAzb7
Error building Flet app - see the log of failed command above.

View parameter 'appbar' not working

When i create an AppBar and want to add it to the View then i need to add it to the controls list. In View there is the parameter appbar but when i assign my AppBar to that then it won't show up.

This does not work:

        ft.View(
            appbar=appbar
        )

This does work:

        ft.View(
            controls=[
                appbar
            ]
        )

page.client_storage and page.session not work in screens view

i created a login with the page page which is in the screens folder. I have set the value in page.client_storage and session storage. but when you get the data it's actually None . What is wrong . i wanto logout for remove login key in client storage in session storage but value always None

from flet import *
from flet_route import Routing,path
from screens.login import LoginView
from screens.register import RegisterView
from screens.dashboard import DashboardView

def main(page:Page):
    my_routes = [
        path(
            url="/register",
            clear=True,
            view=RegisterView
            ),
        path(
            url="/login",
            clear=True,
            view=LoginView
            ),
        path(
            url="/dashboard",
            clear=True,
            view=DashboardView
            ),
    ]
    check_login_session = page.client_storage.get("login")
    print(check_login_session)
    Routing(page=page,app_routes=my_routes)
    if check_login_session == None:
        page.go("/login")
        page.update()
    else:
        page.go("/dashboard")
        page.update()

    page.go(page.route)

flet.app(target=main)

file screens/login.py

from flet import *
from flet_route import Params,Basket
import random
import string
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from myconnect import mycursor,mydb


def LoginView(page:Page,params:Params,basket:Basket):
	nametxt = TextField(label="email")
	passwordtxt = TextField(label="password")


	def is_email_verified(email):
	    mycursor.execute("SELECT is_verified FROM users WHERE email = %s", (nametxt.value,))
	    result = mycursor.fetchone()
	    if result[0] == 1:
	        return True
	    else:
	        return False

	def loginprocess(e):
		mycursor.execute("SELECT * FROM users WHERE email = %s AND password = %s", (nametxt.value, passwordtxt.value))
		result = mycursor.fetchone()
		get_token = result[4]

		if not result:
			print("Email atau password salah")
			page.snack_bar = SnackBar(
				Text("Wrong email password",size=30),
				bgcolor="red"
				)
			page.snack_bar.open = True
			page.update()
			return
		elif not is_email_verified(nametxt.value):
			print("Email belum terverifikasi")
			page.snack_bar = SnackBar(
				Text("you email not verified",size=30),
				bgcolor="red"
				)
			page.snack_bar.open = True
			page.update()
			return
		
		print("Anda sudah di dashboard")
		page.go("/dashboard")
		page.client_storage.set("login",get_token)
		page.update()

	return View(
		"/login",
		controls=[
			Text("you login page",size=30,weight="bold"),
			nametxt,
			passwordtxt,
			ElevatedButton("login Now",
				bgcolor="green",color="white",
				on_click=loginprocess
				),
			Row([
			TextButton("no have account,register",
				on_click=lambda e:page.go("/register")
				)
				],alignment="center")
			]
		)

file screens/register.py

from flet import *
from flet_route import Params,Basket
import random
import string
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

from myconnect import mycursor,mydb

def RegisterView(page:Page,params:Params,basket:Basket):
	nametxt = TextField(label="email")
	passwordtxt = TextField(label="password")


	def send_verification_email(email, token):
	    subject = "Verifikasi Email"
	    body = "Klik link berikut untuk melakukan verifikasi email: http://localhost:5000/verify_email?token=" + token + "&email=" + email

	    message = MIMEMultipart()
	    message['From'] = "[email protected]"
	    message['To'] = email
	    message['Subject'] = subject
	    message.attach(MIMEText(body, 'plain'))

	    # koneksi ke SMTP server Mailtrap dan kirim email
	    with smtplib.SMTP('smtp.mailtrap.io', 2525) as smtp:
	        smtp.login("27b3da367addfa", "bc4d9ff24e96cb")
	        smtp.sendmail("[email protected]", email, message.as_string())

	def generate_token():
	    letters = string.ascii_letters
	    return ''.join(random.choice(letters) for i in range(10))


	def registerprocess(e):
		mycursor.execute("SELECT * FROM users WHERE email = %s", (nametxt.value,))
		result = mycursor.fetchone()
		if result:
			print("Email sudah terdaftar")
			return
		token = generate_token()
		sql = "INSERT INTO users (email, password, verification_token) VALUES (%s, %s, %s)"
		val = (nametxt.value, passwordtxt.value, token)
		mycursor.execute(sql, val)
		mydb.commit()
		send_verification_email(nametxt.value, token)
		print("Registrasi berhasil, silakan cek email untuk verifikasi")
		page.snack_bar = SnackBar(
			Text("Send Email Verification",size=30),
			bgcolor="blue"
			)
		page.snack_bar.open = True
		nametxt.value = ""
		passwordtxt.value = ""
		page.update()


	return View(
		"/register",
		controls=[
			Text("you register ",size=30,weight="bold"),
			nametxt,
			passwordtxt,
			ElevatedButton("Register my account",
			bgcolor="blue",color="white",
			on_click=registerprocess
				),
			ElevatedButton("Login Now",
			bgcolor="orange",color="white",
			on_click=lambda e:page.go("/login")
				)
			]
		)

file screens/dashboard.py

from flet import *
from flet_route import Params,Basket

def DashboardView(page:Page,params:Params,basket:Basket):
	page.bgcolor="green"
	check_login_session = page.client_storage.get("login")
	print("hasil",check_login_session)
	if check_login_session == None:
		page.go("/login")
		page.update()

	def logoutnow(e):
		page.client_storage.remove("login")
		page.go("/login")
		page.update()

	return View(
		"/dashboard",
		controls=[
		Text("You In Dashboard",size=30,weight="bold",
			),
		ElevatedButton("logout",
			bgcolor="red",color="white",
			on_click=logoutnow
			)
		]
		)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.