{"id":13685252,"url":"https://github.com/PauloniaAQP/paulonia_cache_image","last_synced_at":"2025-05-01T01:31:09.747Z","repository":{"id":43689431,"uuid":"293157410","full_name":"PauloniaAQP/paulonia_cache_image","owner":"PauloniaAQP","description":"Flutter package for cache images in storage or memory from  the network or Google Cloud Storage. It supports Android, iOS and Web.","archived":false,"fork":false,"pushed_at":"2023-10-14T19:18:15.000Z","size":271,"stargazers_count":8,"open_issues_count":11,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-12T06:34:28.839Z","etag":null,"topics":["cache","cache-image","flutter","flutter-package","gcp","google-storage"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PauloniaAQP.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-05T21:31:17.000Z","updated_at":"2023-10-14T19:17:35.000Z","dependencies_parsed_at":"2023-10-15T17:40:55.658Z","dependency_job_id":"0ebe6b0d-6905-4408-b00e-e1aace6bac4e","html_url":"https://github.com/PauloniaAQP/paulonia_cache_image","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloniaAQP%2Fpaulonia_cache_image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloniaAQP%2Fpaulonia_cache_image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloniaAQP%2Fpaulonia_cache_image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloniaAQP%2Fpaulonia_cache_image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PauloniaAQP","download_url":"https://codeload.github.com/PauloniaAQP/paulonia_cache_image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251808429,"owners_count":21647291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","cache-image","flutter","flutter-package","gcp","google-storage"],"created_at":"2024-08-02T14:00:47.540Z","updated_at":"2025-05-01T01:31:09.416Z","avatar_url":"https://github.com/PauloniaAQP.png","language":"Dart","funding_links":[],"categories":["Dart"],"sub_categories":[],"readme":"# Paulonia Cache Image\n[![codecov](https://codecov.io/gh/PauloniaAQP/paulonia_cache_image/branch/master/graph/badge.svg?token=UIMGQXYSFU)](https://codecov.io/gh/PauloniaAQP/paulonia_cache_image) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nFlutter package for download and store images in cache. It supports in-memory and storage cache in Android, iOS and Web for network and Google Cloud Storage images.\n\n![Gif](https://i.imgur.com/AsqxrUz.gif)\n\n## Usage\n\nTo use this package add `paulonia_cache_image` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). \n\nYou have to initialize the package in your `main()` function:\n\n```dart\nvoid main() async{\n  WidgetsFlutterBinding.ensureInitialized();\n  await PCacheImage.init();\n  runApp(MyApp());\n}\n```\nIn the `init()` function you can initialize the default values of the [Properties of ImageProvider](https://pub.dev/packages/paulonia_cache_image#properties). You can change a value in all Paulonia cache image widgets in your app.\n\n\nPaulonia cache image extends `ImageProvider`, so you can use it with any widget that supports an `ImageProvider` only with the URL. By default, the image is cached in the platform storage:\n```dart\nImage(\n  image: PCacheImage('https://i.imgur.com/jhRBVEp.jpg')\n);\nImage(\n  image: PCacheImage(\n    'gs://flutter-template-44674.appspot.com/images/user/0ooAw4dX5AeGhkH1JYkoWcdwvc72_big.jpg',\n  )\n);\n```\n\n### In-memory cache\n\nWith the default image cache in the platform storage there is a problem: when you make a `setState()` the package reads the storage and retrieve the image, this process causes the image to **flicker!**. With in-memory cache, this process is more quickly and there is no flicker. You can enable it as follows:\n\n\n```dart\nImage(\n  image: PCacheImage('https://i.imgur.com/jhRBVEp.jpg', enableInMemory: true)\n);\n```\nYou can enable in-memory cache in all `PCacheImage` widgets in the `init()` function:\n```dart\nvoid main() async{\n  WidgetsFlutterBinding.ensureInitialized();\n  await PCacheImage.init(enableInMemory: true);\n  runApp(MyApp());\n}\n```\n**Use only where your require**. The problem with this approach is the memory usage increase. We recommend use only with images in widgets that run `setState()`, to erase the flicker. To avoid an uncontrollable memory growth you can set the maximum number of images that to be stored in memory:\n\n```dart\nvoid main() async{\n  WidgetsFlutterBinding.ensureInitialized();\n  await PCacheImage.init(enableInMemory: true, maxInMemoryImages: 5);\n  runApp(MyApp());\n}\n```\n\nThis functionality works as a queue, to save a new image to memory, the oldest one is deleted.\n\n### Clear Entire Cache\n\nThere could be situations where you might want to clear the whole cache may be to rebuild the cache again. Calling the following method will empty the cache.\n\n```dart\nawait PCacheImage.clearAllCacheImages();\n```\n\n## CORS on web\n\nOn the web when you try to make a request and download an image, it can throw an error with the CORS. Depends on the image type there is a solution:\n\n### Google Storage Images\n\nYou must to [enable CORS in your bucket](https://firebase.google.com/docs/storage/web/download-files#cors_configuration)\n\n### Network Images\n\nYou can set a proxy in the `init()` function:\n\n```dart\nvoid main() async{\n  WidgetsFlutterBinding.ensureInitialized();\n  await PCacheImage.init(proxy: \"https://cors-anywhere.herokuapp.com/\");\n  runApp(MyApp());\n}\n```\n\nThe `proxy` property is only used with network image in the way: \"https://cors-anywhere.herokuapp.com/http://image.jpg\".\n\n## Properties\n\n`PCacheImage` has the follow properties:\n\nProperty | What does it do | Default\n-------- | --------------- | --------\nenableInMemory | Enable or disable the in-memory cache | false\nenableCache | Enable or disable the cache | true\nretryDuration | If the download fails, retry after this duration | 2s\nmaxRetryDuration | Max accumulated time of retries | 10s\nimageScale | The image scale | 1.0\nmaxInMemoryImages | Global variable, sets a max number of images in memory | 7\nclearCacheImage | Deletes the image from cache | false\n\n## Author\n\nThis packaged was made by [ChrisChV](https://github.com/ChrisChV) and is used in all Paulonia projects.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPauloniaAQP%2Fpaulonia_cache_image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPauloniaAQP%2Fpaulonia_cache_image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPauloniaAQP%2Fpaulonia_cache_image/lists"}