Skip to main content

book_view_flutter 0.2.0 copy "book_view_flutter: ^0.2.0" to clipboard
book_view_flutter: ^0.2.0 copied to clipboard

A premium, realistic book card widget for Flutter with a 3D-like spine effect, customizable shadows, and deep theming support.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'BookView Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const BookGalleryPage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Ma Bibliothèque Réaliste'),
        centerTitle: true,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: GridView.builder(
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            childAspectRatio: 0.6,
            crossAxisSpacing: 16,
            mainAxisSpacing: 16,
          ),
          itemCount: books.length,
          itemBuilder: (context, index) {
            final book = books[index];
            if (book.isAsset) {
              return BookView.asset(
                assetPath: book.imageUrl,
                title: book.title,
                author: book.author,
                priceLabel: book.price,
                purchasedLabel: 'Purchased', // Example of i18n
                isPurchased: book.isPurchased,
                readingProgress: book.readingProgress,
                ribbonText: book.ribbonText,
                onTap: () => _onBookTap(context, book),
              );
            }
            return BookView(
              imageUrl: book.imageUrl,
              title: book.title,
              author: book.author,
              priceLabel: book.price,
              purchasedLabel: 'Purchased', // Example of i18n
              isPurchased: book.isPurchased,
              readingProgress: book.readingProgress,
              ribbonText: book.ribbonText,
              onTap: () => _onBookTap(context, book),
            );
          },
        ),
      ),
    );
  }

  void _onBookTap(BuildContext context, BookData book) {
    ScaffoldMessenger.of(
      context,
    ).showSnackBar(SnackBar(content: Text('Ouverture de : ${book.title}')));
  }
}

class BookData {
  final String title;
  final String author;
  final String imageUrl;
  final String? price;
  final bool isPurchased;
  final bool isAsset;
  final double? readingProgress;
  final String? ribbonText;

  BookData({
    required this.title,
    required this.author,
    required this.imageUrl,
    this.price,
    this.isPurchased = false,
    this.isAsset = false,
    this.readingProgress,
    this.ribbonText,
  });
}

final List<BookData> books = [
  BookData(
    title: 'Mon Livre Asset 1',
    author: 'Innocent K.',
    imageUrl: 'assets/images/1.jpg',
    price: '950 F',
    isAsset: true,
    ribbonText: 'NOUVEAU',
  ),
  BookData(
    title: 'Mon Livre Asset 2',
    author: 'Innocent K.',
    imageUrl: 'assets/images/2.jpg',
    isPurchased: true,
    isAsset: true,
    readingProgress: 0.35,
  ),
  BookData(
    title: 'L\'Art de la Guerre',
    author: 'Sun Tzu',
    imageUrl:
        'https://images.unsplash.com/photo-1544947950-fa07a98d237f?q=80&w=300&auto=format&fit=crop',
    price: '1500 F',
    ribbonText: 'BESTSELLER',
  ),
  BookData(
    title: 'Clean Architecture',
    author: 'Robert C. Martin',
    imageUrl:
        'https://images.unsplash.com/photo-1589998059171-988d887df646?q=80&w=300&auto=format&fit=crop',
    isPurchased: true,
    readingProgress: 0.82,
  ),
  BookData(
    title: 'Design Patterns',
    author: 'Erich Gamma',
    imageUrl:
        'https://images.unsplash.com/photo-1532012197267-da84d127e765?q=80&w=300&auto=format&fit=crop',
    price: '2500 F',
  ),
  BookData(
    title: 'Flutter in Action',
    author: 'Eric Windmill',
    imageUrl:
        'https://images.unsplash.com/photo-1512820790803-83ca734da794?q=80&w=300&auto=format&fit=crop',
    price: '1800 F',
    ribbonText: '-50%',
  ),
];
1
likes
130
points
81
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A premium, realistic book card widget for Flutter with a 3D-like spine effect, customizable shadows, and deep theming support.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

cached_network_image, flutter, shimmer

More

Packages that depend on book_view_flutter