odoo_image_show 3.0.0 copy "odoo_image_show: ^3.0.0" to clipboard
odoo_image_show: ^3.0.0 copied to clipboard

A Flutter package to display profile images from the Odoo API with progress indication, error handling, and customization.

odoo_image_show #

odoo_image_show is a Flutter package designed to display profile images from Odoo APIs (v17, v18, v19) with ease.
It uses dio for efficient networking and automatically extracts authentication details (like session_id and access_token) from the provided image URL.

Features #

  • Unified Widget: One widget (OdooImage) for all Odoo versions.
  • Automatic Auth Extraction: Extracts session_id and access_token directly from the URL query parameters.
  • Customizable: Set image size, border color, fallback icons, and custom loading/error builders.
  • Progress Indication: Built-in progress indicator while the image is downloading.
  • Backward Compatible: Maintains OdooProfileImage and Odoo19ProfileImage as deprecated aliases.

Getting Started #

Add the dependency in your pubspec.yaml:

dependencies:
  odoo_image_show: ^3.0.0

Then run:

flutter pub get

Usage #

Set the session ID once (e.g., after login) and use OdooImage with just the URL everywhere.

// Set this once in your app (e.g. main.dart or after login)
OdooImage.rootSessionId = "12345xxxxx"; 

// Then usage is simple:
OdooImage(
  imageUrl: 'https://domain/web/image/hr.employee/employee_id/image_1920',
  size: 100,
)

2. Explicit Session ID #

You can also pass the session ID to specific widgets if you need to override the global one.

OdooImage(
  imageUrl: 'https://domain/web/image/hr.employee/employee_id/image_1920',
  sessionId: '12345xxxxx', 
  size: 100,
  borderColor: Colors.blue,
)

3. Integration with Storage (Shared Preferences / Secure Storage) #

You can easily pass the session ID you retrieved from local storage.

// Example with a FutureBuilder or a state management solution
FutureBuilder<String?>(
  future: SecureStorage.getSessionId(), // Your storage logic
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      return OdooImage(
        imageUrl: '...',
        sessionId: snapshot.data, // Pass the stored session ID here
      );
    }
    return CircularProgressIndicator();
  },
)

Features #

  • Authenticated Image Loading: Supports both session_id (Cookie) and access_token (Bearer).
  • Automatic Extraction: Parses credentials from URL if not provided explicitly.
  • Progress & Error Handling: Built-in loading indicator and error placeholder.
  • Customizable: Control size, borders, and custom builders for loading/error states.

Example App #

import 'package:flutter/material.dart';
import 'package:odoo_image_show/odoo_image_show.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: OdooImage(
            imageUrl: "https://example.com/web/image/res.users/1/image_128?session_id=XYZ",
          ),
        ),
      ),
    );
  }
}

Additional Information #

  • Error Handling: Displays a fallback icon or a custom widget if fetching fails.
  • Loading: Shows a progress indicator by default.
  • Dio: Uses the dio package for all network requests.

📝 License #

MIT License. Designed with ❤️ for the Flutter community.

🧑‍💻 Developer #

Md. Rahul Reza GitHub | LinkedIn | Website

1
likes
160
points
238
downloads

Publisher

verified publisherrahulreza.com

Weekly Downloads

A Flutter package to display profile images from the Odoo API with progress indication, error handling, and customization.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, intl, path_provider

More

Packages that depend on odoo_image_show