Features

He work of this package is when the list shows this data with the help of http package, it will be saved through shared preferences package.You had to do this yourself, so this package

Usage

Include short and useful examples for package users. Add longer examples to /example folder.

import 'package:cached_network_image/cached_network_image.dart'; // Image Save Cached
import 'package:http_store/http_store.dart'; // install this package
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePageList(),
    );
  }
}

class HomePageList extends StatefulWidget {
  const HomePageList({super.key});

  @override
  State<HomePageList> createState() => _HomePageListState();
}

class _HomePageListState extends State<HomePageList> {
  var bookType = 'audiobooks';

  @override
  Widget build(BuildContext context) {
    final double screenWidth = MediaQuery.of(context).size.width;
    final double imageWidth = (screenWidth - 40) / 3;
    final double imageHeight = imageWidth * 1.5;
    return Scaffold(
      appBar: AppBar(),
      body: SizedBox(
        height: imageHeight + 10,
        child: HttpStore(
          apiKey:
              'https://apon06.github.io/bookify_api/sarat_chandra_chattopadhyay.json',
          saveKey: 'Hello',
          bookType: bookType,
          builder: (context, data) {
            return ListView.builder(
              scrollDirection: Axis.horizontal,
              itemCount: data.length,
              itemBuilder: (context, index) {
                dynamic book = data[index];
                return Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 5.0),
                  child: GestureDetector(
                    //! uncomment
                    // onTap: () {
                    //   Navigator.of(context).push(
                    //     MaterialPageRoute(
                    //       builder: (builder) =>
                    //           EpisodeListPage(audiobook: book),
                    //     ),
                    //   );
                    // },
                    child: Container(
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(15),
                        boxShadow: const [
                          BoxShadow(
                            color: Colors.black26,
                            spreadRadius: 1,
                            blurRadius: 5,
                          ),
                        ],
                      ),
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(8),
                        child: CachedNetworkImage(
                          imageUrl: book["bookImage"].toString(),
                          width: imageWidth,
                          height: imageHeight,
                          fit: BoxFit.cover,
                          placeholder: (context, url) => Container(
                            width: imageWidth,
                            height: imageHeight,
                            color: Colors.grey[200],
                            child: const Center(
                              child: CircularProgressIndicator(),
                            ),
                          ),
                          errorWidget: (context, url, error) => Container(
                            width: imageWidth,
                            height: imageHeight,
                            color: Colors.grey[200],
                            child: const Icon(Icons.error),
                          ),
                        ),
                      ),
                    ),
                  ),
                );
              },
            );
          },
        ),
      ),
    );
  }
}

//! uncomment
// class EpisodeListPage extends StatelessWidget {
//   final dynamic audiobook;
//   const EpisodeListPage({super.key, required this.audiobook});

//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: Text(
//           audiobook['bookName'],
//           style: const TextStyle(
//             fontSize: 20,
//             fontWeight: FontWeight.bold,
//           ),
//         ),
//       ),
//       body: CustomScrollView(
//         slivers: [
//           SliverToBoxAdapter(
//             child: Column(
//               children: [
//                 Padding(
//                   padding: const EdgeInsets.all(16.0),
//                   child: Container(
//                     decoration: BoxDecoration(
//                       borderRadius: BorderRadius.circular(15),
//                       boxShadow: const [
//                         BoxShadow(
//                           color: Colors.black26,
//                           spreadRadius: 1,
//                           blurRadius: 5,
//                         ),
//                       ],
//                     ),
//                     child: ClipRRect(
//                       borderRadius: BorderRadius.circular(8),
//                       child: CachedNetworkImage(
//                         imageUrl: audiobook['bookImage'],
//                         fit: BoxFit.cover,
//                       ),
//                     ),
//                   ),
//                 ),
//                 Padding(
//                   padding: const EdgeInsets.symmetric(horizontal: 16.0),
//                   child: Text(
//                     'নাম: ${audiobook['bookName']}',
//                     style: const TextStyle(
//                       fontSize: 24,
//                       fontWeight: FontWeight.bold,
//                     ),
//                     textAlign: TextAlign.center,
//                   ),
//                 ),
//                 Padding(
//                   padding: const EdgeInsets.symmetric(
//                       horizontal: 16.0, vertical: 8.0),
//                   child: Text(
//                     'লেখক: ${audiobook['bookCreatorName']}',
//                     style: const TextStyle(
//                       fontSize: 16,
//                     ),
//                     textAlign: TextAlign.center,
//                   ),
//                 ),
//               ],
//             ),
//           ),
//           SliverList(
//             delegate: SliverChildBuilderDelegate(
//               (context, index) {
//                 final episode = audiobook['episodes'][index];
//                 return Padding(
//                   padding:
//                       const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
//                   child: Card(
//                     elevation: 4,
//                     shape: RoundedRectangleBorder(
//                       borderRadius: BorderRadius.circular(8),
//                     ),
//                     child: ListTile(
//                       title: Text(
//                         episode['bookName'],
//                         style: const TextStyle(
//                           fontSize: 18,
//                           fontWeight: FontWeight.w500,
//                         ),
//                       ),
//                       trailing: const Icon(
//                         Icons.navigate_next,
//                         color: Colors.deepPurple,
//                       ),
//                       onTap: () {
//                       },
//                     ),
//                   ),
//                 );
//               },
//               childCount: audiobook['episodes'].length,
//             ),
//           ),
//         ],
//       ),
//     );
//   }
// }

Additional information

The main function of this package is to save data offline. But the limitation of the package is that it can only save list data. "int","double","bool" cannot be done in this package. So why use this package? This makes it easier for you to write an extra 30-35 lines of code. If you want to save other data type then this package does not support it. May do in the future. This package is mainly made with http+shared_preferences

The package used to build this package

  1. shared_preferences
  2. http

My Other Open Source Project

Israel has killed 40,000 civilians in Gaza so far. Please help them. Free Palestine ❤❤

Libraries

http_store