imagex_flutter 0.0.3
imagex_flutter: ^0.0.3 copied to clipboard
A reusable Flutter image widget for asset, network, SVG, and file images.
import 'package:flutter/material.dart';
import 'package:imagex_flutter/imagex_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ImageX Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const ImageXExample(),
);
}
}
class ImageXExample extends StatelessWidget {
const ImageXExample({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('ImageX Example'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: const SingleChildScrollView(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Network Image',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
ImageX(
path:
'https://raw.githubusercontent.com/saurabhkumar-sk/imagex_flutter/main/example/assets/demo_image.png',
height: 200,
width: double.infinity,
fit: BoxFit.cover,
borderRadius: 12,
useImageViewer: true,
),
SizedBox(height: 24),
Text(
'SVG Image (Network)',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
ImageX(
path:
'https://raw.githubusercontent.com/dnfield/flutter_svg/7d374d7107561aa038166d1363666579df646091/example/assets/flutter_logo.svg',
height: 100,
width: 100,
),
SizedBox(height: 24),
Text(
'Image with Viewer (Gallery)',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
ImageX(
path: 'https://picsum.photos/id/237/400/300',
height: 200,
width: double.infinity,
fit: BoxFit.cover,
borderRadius: 12,
useImageViewer: true,
imageList: [
'https://picsum.photos/id/237/800/600',
'https://picsum.photos/id/238/800/600',
'https://picsum.photos/id/239/800/600',
],
),
SizedBox(height: 24),
Text(
'Error Handling',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
ImageX(
path: 'https://invalid-url.com/image.png',
height: 100,
width: 100,
borderRadius: 8,
),
SizedBox(height: 40),
Center(
child: Text(
'Note: Asset and File images require setup in pubspec.yaml and local files.',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey),
),
),
],
),
),
);
}
}