Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Oct 1, 2025

Fix #1938

Test Code

import flet as ft


async def main(page: ft.Page):
    info = await page.get_device_info()
    page.add(ft.Text(str(info)))

    if page.web:
        print(type(info.browser_name))


ft.run(main)

Note

  • page.client_user_agent could be removed in favor of page.get_device_info().user_agent for web

Summary by Sourcery

--
Implement a unified page.get_device_info() API across Python and Flutter SDKs, including new platform-specific DeviceInfo types and a Dart mapping layer, and upgrade the device_info_plus dependency.

New Features:

  • Add get_device_info() method to Page in Python SDK and to Flutter PageControl for retrieving device information.
    Enhancements:

  • Introduce platform-specific DeviceInfo dataclasses and WebBrowserName enum in Python SDK for typed device info.
    Add Dart utility and BaseDeviceInfo extension to map device_info_plus data into a structured JSON representation.
    Build:

  • Bump Flutter device_info_plus dependency from ^11.2.0 to ^12.1.0.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a page.get_device_info() method to retrieve device information across different platforms (Web, Android, iOS, macOS, Linux, Windows). The implementation provides platform-specific device information classes with comprehensive device details.

  • Adds new get_device_info() method to the Page class that returns platform-specific device information
  • Creates comprehensive device information data structures for all supported platforms
  • Upgrades device_info_plus dependency to enable additional device information features

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/controls/page.py Adds the get_device_info() method that returns platform-specific device info objects
sdk/python/packages/flet/src/flet/controls/device_info.py Defines comprehensive device information data classes for all platforms
sdk/python/packages/flet/src/flet/init.py Exports all device info classes in the public API
packages/flet/pubspec.yaml Upgrades device_info_plus dependency from ^11.2.0 to ^12.1.0
packages/flet/lib/src/utils/device_info.dart Implements device info collection logic for Flutter/Dart side
packages/flet/lib/src/controls/page.dart Adds device info method handler and minor theme parsing improvements
sdk/python/packages/flet/src/flet/controls/layout_control.py Adds missing ConstrainedControl to all exports
sdk/python/packages/flet/src/flet/controls/core/keyboard_listener.py Adds missing keyboard event classes to all exports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 1, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 46dd7f4
Status: ✅  Deploy successful!
Preview URL: https://54b22ca0.flet-docs.pages.dev
Branch Preview URL: https://device-info.flet-docs.pages.dev

View logs

@FeodorFitsner
Copy link
Contributor

FeodorFitsner commented Oct 1, 2025

  • Need to add classes from device_info.py to docs under "Types".

@FeodorFitsner
Copy link
Contributor

I'd keep page.client_user_agent for now as it's being used internally in flet_web package.

ndonkoHenri and others added 5 commits October 1, 2025 23:36
Replaced direct class instantiation with the from_dict utility for device info objects in Page.get_device_info. This improves consistency and handles dictionary-to-object conversion more robustly.
Introduces JSAny type and conditional JS interop import for Dart, enabling serialization of JS interop objects in FletMsgpackEncoder. Updates protocol.py to handle new ext type code for JSAny. Also comments out unused HTML view sections and updates PyPI cleanup version pattern.
@FeodorFitsner FeodorFitsner merged commit 6590f1f into main Oct 2, 2025
23 of 42 checks passed
@FeodorFitsner FeodorFitsner deleted the device-info branch October 2, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting android id or uuid for iOS devices to uniquely identify users

3 participants