odoo_image_show 3.0.0
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.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:odoo_image_show/odoo_image_show.dart';
void main() {
// Example of setting global session ID
OdooImage.rootSessionId = "global_session_id_example";
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Odoo Image Show Demo',
theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.blue),
home: const ProfilePage(),
);
}
}
class ProfilePage extends StatelessWidget {
const ProfilePage({super.key});
@override
Widget build(BuildContext context) {
// Example URLs
const imageUrl =
"https://domain/web/image/hr.employee/employee_id/image_1920";
const sessionId = "sesssion_id";
return Scaffold(
appBar: AppBar(title: const Text("Odoo Image Show"), centerTitle: true),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Global Session ID (Implicit)",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const OdooImage(
imageUrl: imageUrl, // Uses OdooImage.rootSessionId
size: 150,
borderColor: Colors.purple,
),
const SizedBox(height: 32),
const Text(
"Explicit Session ID (Overriding Global)",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const OdooImage(
imageUrl: imageUrl,
sessionId: sessionId,
size: 150,
borderColor: Colors.blue,
),
const SizedBox(height: 32),
const Text(
"Session ID in URL (Legacy)",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const OdooImage(
imageUrl: "$imageUrl?session_id=$sessionId",
size: 150,
borderColor: Colors.green,
),
const SizedBox(height: 32),
const Text(
"Custom Error Builder",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
OdooImage(
imageUrl: "https://invalid-url.com/image",
size: 150,
errorBuilder:
(context) => Container(
width: 150,
height: 150,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.red.shade50,
shape: BoxShape.circle,
border: Border.all(color: Colors.red),
),
child: const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.broken_image, color: Colors.red, size: 40),
Text("Failed", style: TextStyle(color: Colors.red)),
],
),
),
),
],
),
),
),
);
}
}