question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Saving and retreiving a string value from client storage adds quotation marks

See original GitHub issue

Description

Saving and retreiving a string value from the client storage adds quotation marks around it.

Code example to reproduce the issue:

import flet
from flet import Page, TextField


class MyApp:
    @staticmethod
    def static_run(page: Page) -> None:
        MyApp(page)

    def __init__(self, page: Page):
        self.page: Page = page
        self.text_field = TextField(label="Value Store", value=self.get_text(), on_submit=self.save_text)
        self.page.add(self.text_field)
        self.text_field.focus()

    def get_text(self) -> str:
        key = "text"
        if self.page.client_storage.contains_key(key):
            return self.page.client_storage.get(key)
        else:
            return "Enter some text here."

    def save_text(self, e):
        key = "text"
        self.page.client_storage.set(key, self.text_field.value)


if __name__ == '__main__':
    flet.app(target=MyApp.static_run, assets_dir="assets")
    # flet.app(target=MyApp.static_run, assets_dir="assets", view=flet.WEB_BROWSER, port=8080)

Describe the results you received:

  1. Start the application
  2. Enter some text and press enter to save it to client storage

image 3. Stop and reopen the app. There are now quotations around the text

image

Flet version (pip show flet):

Version: 0.1.63

Operating system:

Arch Linux x86

Additional environment details: I am using a venv with these requirements installed:

  • flet
  • py-staticmaps[cairo]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
FeodorFitsnercommented, Nov 3, 2022

It will be closed automatically when PR is merged.

1reaction
FeodorFitsnercommented, Nov 2, 2022

Fixed in the next release coming later this week.

For workaround unwrap the value with json.loads(), for example:

v = json.loads(page.client_storage.get("AAA"))
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML5 localstorage adding in double quotes - Stack Overflow
localStorage always store the string data with double quotes, when you are retrieving the same data you will get with double quotes.
Read more >
Stores double quotes as part of a string · Issue #174 - GitHub
In one part of my app I am storing a string in localStorage to correctly set the app theme on page load const...
Read more >
Why you may need quotation marks in CSV files?
In CSV files, quotation marks function as text qualifiers. This means that they define what text should be stored as a single value...
Read more >
Understanding Quotation Marks in PowerShell - Scripting Blog
Windows PowerShell can't recognize a string value unless delimiters (or boundaries) are defined by the user. In Windows PowerShell, single and ...
Read more >
MySQL 8.0 Reference Manual :: 9.1.1 String Literals
In certain client environments, it may also be necessary to escape NUL or Control+Z. The mysql client truncates quoted strings containing NUL characters...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found