diff --git a/packages/ready_image/.flutter-plugins-dependencies b/packages/ready_image/.flutter-plugins-dependencies index af03dce..efec352 100644 --- a/packages/ready_image/.flutter-plugins-dependencies +++ b/packages/ready_image/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_ios","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.7/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2/","dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.11/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.5/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.5/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.5/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-04-11 01:36:51.047638","version":"2.10.4"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_ios","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.7/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2/","dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.11/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.5/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.5/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.5/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-04-18 01:02:40.493601","version":"2.10.4"} \ No newline at end of file diff --git a/packages/ready_image/README.md b/packages/ready_image/README.md index 8b55e73..8f6e157 100644 --- a/packages/ready_image/README.md +++ b/packages/ready_image/README.md @@ -1,39 +1,69 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. +```dart +/// only the path property is required + ReadyImage( + path: //url or just file name as the there is a global url resolver that can handle the url, + height: /// image height, + width: /// image width + queryParameters: /// query parameters to be added to the url, + resolveUrl: /// url resolver to override the global one, + imageRenderMethodForWeb: /// how web images can be handled, + errorPlaceholder: /// widget in case of error, + loadingPlaceholder: /// widget while loading, + foregroundDecoration: /// decoration to be applied above the image, + decoration: /// decoration behind the image, + outerDecoration:/// decoration behind the image and its decoration , + outerPadding: /// the padding between the outer decoration and the image decoration, + innerPadding: /// padding between the image and its decoration, + fit: /// , + headers:/// headers to be passed , + cacheManager:/// image cacheManager , + forceForegroundRadiusSameAsBackground: /// if true will override the foreground border radius to be the sme as background, + + ), +``` -## Features +### You can also configure these properties globally so that all images in your app can have the same shape -TODO: List what your package can do. Maybe include images, gifs, or videos. +```dart +/// all of these properties are optional + ReadyImageConfig( + resolveUrl: (context, path) => Uri.parse('http://someurl/$path'), + imageRenderMethodForWeb: , + errorPlaceholder: , + loadingPlaceholder: , + foregroundDecoration: , + decoration: , + outerDecoration: , + outerPadding: EdgeInsetsDirectional.only(start: 20), + innerPadding: , + fit: , + headers: , + cacheManager: , + forceForegroundRadiusSameAsBackground: , + child: MaterialApp(), + ) +``` -## Getting started +### this alow has its own hero image which animate all of its decoration while navigating from one screen to other -TODO: List prerequisites and provide or point to information on how to -start using the package. +```dart + HeroReadyImage(path:///) +``` -## Usage +### in some cases you may need to create an image provider not the image it self like in container background -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. +this will allow to make benefit of global configuration ```dart -const like = 'sample'; -``` +Container( + decoration: BoxDecoration(image: context.readyImageDecoration(path: 'path')), + ); -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. +CircleAvatar( + backgroundImage: context.readyImageProvider(path: 'path'), + ); +``` diff --git a/packages/ready_image/example/.flutter-plugins b/packages/ready_image/example/.flutter-plugins new file mode 100644 index 0000000..bf74578 --- /dev/null +++ b/packages/ready_image/example/.flutter-plugins @@ -0,0 +1,8 @@ +# This is a generated file; do not edit or check into version control. +path_provider=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.9/ +path_provider_android=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.12/ +path_provider_ios=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.8/ +path_provider_linux=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.5/ +path_provider_macos=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.5/ +path_provider_windows=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.5/ +sqflite=/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2+1/ diff --git a/packages/ready_image/example/.flutter-plugins-dependencies b/packages/ready_image/example/.flutter-plugins-dependencies new file mode 100644 index 0000000..182ad20 --- /dev/null +++ b/packages/ready_image/example/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_ios","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.8/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2+1/","dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.12/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2+1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.5/","dependencies":[]},{"name":"sqflite","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2+1/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.5/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/dawood/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.5/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-04-18 01:33:47.171319","version":"2.10.4"} \ No newline at end of file diff --git a/packages/ready_image/example/.metadata b/packages/ready_image/example/.metadata new file mode 100644 index 0000000..166a998 --- /dev/null +++ b/packages/ready_image/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: c860cba910319332564e1e9d470a17074c1f2dfd + channel: stable + +project_type: app diff --git a/packages/ready_image/example/README.md b/packages/ready_image/example/README.md new file mode 100644 index 0000000..a135626 --- /dev/null +++ b/packages/ready_image/example/README.md @@ -0,0 +1,16 @@ +# example + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/packages/ready_image/example/analysis_options.yaml b/packages/ready_image/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/packages/ready_image/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/ready_image/example/lib/main.dart b/packages/ready_image/example/lib/main.dart new file mode 100644 index 0000000..14f727d --- /dev/null +++ b/packages/ready_image/example/lib/main.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:ready_image/config.dart'; +import 'package:ready_image/ready_image.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ReadyImageConfig( + resolveUrl: (context, path) { + return Uri.parse('http://site.com/$path'); + }, + child: MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: const MyHomePage(), + ), + ); + } +} + +class MyHomePage extends StatelessWidget { + const MyHomePage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return const ReadyImage(path: 'image_1/.png'); + } +} diff --git a/packages/ready_image/example/pubspec.lock b/packages/ready_image/example/pubspec.lock new file mode 100644 index 0000000..50729b0 --- /dev/null +++ b/packages/ready_image/example/pubspec.lock @@ -0,0 +1,385 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + cached_network_image: + dependency: transitive + description: + name: cached_network_image + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_blurhash: + dependency: transitive + description: + name: flutter_blurhash + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.6" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.4" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + octo_image: + dependency: transitive + description: + name: octo_image + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.12" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + ready_image: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.8" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.27.3" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + sqflite: + dependency: transitive + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2+1" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1+1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0+2" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.8" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.6" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.1" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" +sdks: + dart: ">=2.16.2 <3.0.0" + flutter: ">=2.8.0" diff --git a/packages/ready_image/example/pubspec.yaml b/packages/ready_image/example/pubspec.yaml new file mode 100644 index 0000000..684c562 --- /dev/null +++ b/packages/ready_image/example/pubspec.yaml @@ -0,0 +1,70 @@ +name: example +description: A new Flutter project. + +publish_to: "none" # Remove this line if you wish to publish to pub.dev + +version: 1.0.0+1 + +environment: + sdk: ">=2.16.2 <3.0.0" + +dependencies: + flutter: + sdk: flutter + ready_image: + path: ../ + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^1.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/ready_image/lib/config.dart b/packages/ready_image/lib/config.dart index a010d19..a2a65cf 100644 --- a/packages/ready_image/lib/config.dart +++ b/packages/ready_image/lib/config.dart @@ -25,20 +25,47 @@ class ReadyImageConfig extends InheritedWidget { required Widget child, }) : super(key: key, child: child); + /// manage how the url can be parsed final Uri Function(BuildContext context, String path)? resolveUrl; + + /// manage how web platform load images final ImageRenderMethodForWeb Function(BuildContext context)? imageRenderMethodForWeb; + + /// manage the error widget final LoadingErrorWidgetBuilder? errorPlaceholder; + + /// manage the loading widget final ProgressIndicatorBuilder? loadingPlaceholder; + + /// [ReadyImage.foregroundDecoration] final Decoration Function(BuildContext context)? foregroundDecoration; + + /// [ReadyImage.decoration] final Decoration Function(BuildContext context)? decoration; + + /// [ReadyImage.outerDecoration] final Decoration Function(BuildContext context)? outerDecoration; + + /// [ReadyImage.outerPadding] final EdgeInsetsGeometry Function(BuildContext context)? outerPadding; + + /// [ReadyImage.innerPadding] final EdgeInsetsGeometry Function(BuildContext context)? innerPadding; + + /// [ReadyImage.fit] final BoxFit Function(BuildContext context)? fit; + + /// [ReadyImage.headers] final HeadersCallBack? headers; + + /// [ReadyImage.cacheManager] final BaseCacheManager Function(BuildContext context)? cacheManager; + + /// [HeroReadyImage.disableHero] final bool Function(BuildContext context)? disableHero; + + /// [ReadyImage.forceForegroundRadiusSameAsBackground] final bool Function(BuildContext context)? forceForegroundRadiusSameAsBackground; @@ -145,8 +172,7 @@ class ReadyImageDefaults { fit: widget.fit ?? config?.fit?.call(context) ?? BoxFit.contain, headers: widget.headers ?? config?.headers ?? _defaultHeaders, cacheManager: widget.cacheManager ?? config?.cacheManager?.call(context), - disableHero: - widget.disableHero ?? config?.disableHero?.call(context) ?? false, + disableHero: config?.disableHero?.call(context) ?? false, forceForegroundRadiusSameAsBackground: widget.forceForegroundRadiusSameAsBackground ?? config?.forceForegroundRadiusSameAsBackground?.call(context) ?? diff --git a/packages/ready_image/lib/ready_image.dart b/packages/ready_image/lib/ready_image.dart index e5acbc7..d0a7c27 100644 --- a/packages/ready_image/lib/ready_image.dart +++ b/packages/ready_image/lib/ready_image.dart @@ -11,26 +11,59 @@ export 'package:cached_network_image/cached_network_image.dart'; export 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'; export 'package:flutter_cache_manager/flutter_cache_manager.dart'; +/// Wrapper around cashed network image class ReadyImage extends StatelessWidget { + /// the path or the url of the image final String path; + + /// image width final double? width; + + /// image height final double? height; + + /// parameter to be added to the url final Map? queryParameters; + + /// override the global url resolver final Uri Function(BuildContext context, String path)? resolveUrl; + + /// how image will be fetched in web platform final ImageRenderMethodForWeb? imageRenderMethodForWeb; + + /// the error widget final LoadingErrorWidgetBuilder? errorPlaceholder; + + /// the loading pace holder final ProgressIndicatorBuilder? loadingPlaceholder; + + /// the decoration above the image final Decoration? foregroundDecoration; + + /// the decoration behind the image final Decoration? decoration; + + /// the decoration behind the image and its decoration final Decoration? outerDecoration; + + /// the padding between the inner and outer decoration final EdgeInsetsGeometry? outerPadding; + + /// the padding between the decoration and the image final EdgeInsetsGeometry? innerPadding; + + /// image Box fit final BoxFit? fit; + + /// url headers final HeadersCallBack? headers; + + /// The image cache manager final BaseCacheManager? cacheManager; - final bool? disableHero; - final bool? forceForegroundRadiusSameAsBackground; + /// if true will ignore the foreground radius and copy the radius from decoration + final bool? forceForegroundRadiusSameAsBackground; + final Widget Function(ReadyImageDefaults config)? _builder; const ReadyImage({ Key? key, required this.path, @@ -49,9 +82,33 @@ class ReadyImage extends StatelessWidget { this.fit, this.headers, this.cacheManager, - this.disableHero, this.forceForegroundRadiusSameAsBackground, - }) : super(key: key); + }) : _builder = null, + super(key: key); + + /// in case of you need local image with respect of global decorations + const ReadyImage.custom({ + Key? key, + required Widget Function(ReadyImageDefaults config) builder, + this.foregroundDecoration, + this.decoration, + this.outerDecoration, + this.outerPadding, + this.innerPadding, + this.forceForegroundRadiusSameAsBackground, + }) : _builder = builder, + path = '', + width = null, + height = null, + queryParameters = null, + fit = null, + headers = null, + cacheManager = null, + imageRenderMethodForWeb = null, + errorPlaceholder = null, + loadingPlaceholder = null, + resolveUrl = null, + super(key: key); ReadyImageDefaults config(BuildContext context) => ReadyImageDefaults.of(context, this); @@ -61,7 +118,7 @@ class ReadyImage extends StatelessWidget { Widget child; if (p.outerDecoration != null || p.outerPadding != null) { child = Container( - clipBehavior: Clip.antiAlias, + clipBehavior: p.outerDecoration == null ? Clip.none : Clip.antiAlias, decoration: p.outerDecoration, padding: p.outerPadding, child: _build(context), @@ -75,17 +132,18 @@ class ReadyImage extends StatelessWidget { Widget _build(BuildContext context) { var p = config(context); - var child = CachedNetworkImage( - imageUrl: p.resolveUrl(context, path).toString(), - width: width, - height: height, - imageRenderMethodForWeb: p.imageRenderMethodForWeb, - httpHeaders: p.headers(context), - errorWidget: p.errorPlaceholder, - fit: p.fit, - cacheManager: p.cacheManager, - progressIndicatorBuilder: p.loadingPlaceholder, - ); + var child = _builder?.call(p) ?? + CachedNetworkImage( + imageUrl: p.resolveUrl(context, path).toString(), + width: width, + height: height, + imageRenderMethodForWeb: p.imageRenderMethodForWeb, + httpHeaders: p.headers(context), + errorWidget: p.errorPlaceholder, + fit: p.fit, + cacheManager: p.cacheManager, + progressIndicatorBuilder: p.loadingPlaceholder, + ); var decoration = p.decoration ?? const BoxDecoration(); var foreground = p.foregroundDecoration; var force = p.forceForegroundRadiusSameAsBackground == true; @@ -105,18 +163,24 @@ class ReadyImage extends StatelessWidget { } } +/// instead of using the normal hero you can use this as it will animate its properties class HeroReadyImage extends StatelessWidget { final String tag; + + /// whether to disable hero or not + final bool? disableHero; final ReadyImage child; const HeroReadyImage({ Key? key, required this.child, required this.tag, + required this.disableHero, }) : super(key: key); @override Widget build(BuildContext context) { - var disable = ReadyImageDefaults.of(context, child).disableHero == true; + var disable = disableHero ?? + (ReadyImageDefaults.of(context, child).disableHero == true); if (disable) { return child; } @@ -186,7 +250,6 @@ class HeroReadyImage extends StatelessWidget { fit: child.fit, headers: child.headers, cacheManager: child.cacheManager, - disableHero: child.disableHero, forceForegroundRadiusSameAsBackground: child.forceForegroundRadiusSameAsBackground, path: child.path, @@ -197,6 +260,7 @@ class HeroReadyImage extends StatelessWidget { } extension ReadyImageExtension on BuildContext { + /// create [DecorationImage] with respect of global config DecorationImage readyImageDecoration({ required String path, Uri Function(String path)? resolveUrl, @@ -247,6 +311,8 @@ extension ReadyImageExtension on BuildContext { ); } + /// create [ImageProvider] with respect of global config + ImageProvider readyImageProvider({ required String path, Uri Function(String path)? resolveUrl, diff --git a/packages/ready_image/pubspec.yaml b/packages/ready_image/pubspec.yaml index cac63d3..0a8254d 100644 --- a/packages/ready_image/pubspec.yaml +++ b/packages/ready_image/pubspec.yaml @@ -1,6 +1,6 @@ name: ready_image -description: Simple and customizable image -version: 0.0.6 +description: Simple and customizable image which is wrapper for cached network image ad part of ready packages +version: 0.0.8 homepage: https://github.com/mo-ah-dawood/ready environment: