http_store 0.0.1 copy "http_store: ^0.0.1" to clipboard
http_store: ^0.0.1 copied to clipboard

The 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

example/main.dart

// import 'package:cached_network_image/cached_network_image.dart'; // Image Save Cached
import 'package:flutter/material.dart'; // install this package
import 'package:http_store/http_store.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),
                        //! Use this Package "cached_network_image" other wise image not save but any text save.
                        //! uncomment Plz
                        // 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),
                        //   ),
                        // ),

                        //! remove this
                        child: Image.network(
                          book["bookImage"].toString(),
                          width: imageWidth,
                          height: imageHeight,
                        ),
                        //! remove this
                      ),
                    ),
                  ),
                );
              },
            );
          },
        ),
      ),
    );
  }
}

//! 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,
//             ),
//           ),
//         ],
//       ),
//     );
//   }
// }
0
likes
150
points
23
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

The 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

Homepage

License

MIT (license)

Dependencies

flutter, http, shared_preferences

More

Packages that depend on http_store