odoo_image_show 2.1.0
odoo_image_show: ^2.1.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() {
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 with credentials in query params
const imageUrlWithSession =
"https://example.com/web/image/res.users/1/image_128?session_id=fake_session_id";
const imageUrlWithToken =
"https://example.com/web/image/res.users/1/image_128?access_token=fake_access_token";
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(
"Automatic Session ID Extraction",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const OdooImage(
imageUrl: imageUrlWithSession,
size: 150,
borderColor: Colors.blue,
),
const SizedBox(height: 32),
const Text(
"Automatic Access Token Extraction",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const OdooImage(
imageUrl: imageUrlWithToken,
size: 150,
borderColor: Colors.green,
),
const SizedBox(height: 32),
const Text(
"Explicit Credentials",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const OdooImage(
imageUrl:
"https://example.com/web/image/res.users/1/image_128?session_id=explicit_session_id",
size: 150,
borderColor: Colors.orange,
),
const SizedBox(height: 32),
const Text(
"Custom Builders",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
OdooImage(
imageUrl: "https://invalid-url",
size: 150,
errorBuilder:
(context) => const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.error_outline, color: Colors.red, size: 40),
Text(
"Load Failed",
style: TextStyle(color: Colors.red),
),
],
),
),
],
),
),
),
);
}
}