├── pubspec.yaml ├── .gitignore ├── CHANGELOG.md ├── analysis_options.yaml ├── lib └── transparent_image.dart ├── LICENSE └── README.md /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: transparent_image 2 | description: A transparent image in Dart code, represented as a Uint8List. 3 | version: 2.0.1 4 | homepage: https://github.com/brianegan/transparent_image 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .packages 3 | .dart_tool/ 4 | .pub/ 5 | build/ 6 | # Remove the following pattern if you wish to check in your lock file 7 | pubspec.lock 8 | .idea 9 | 10 | # Directory created by dartdoc 11 | doc/api/ 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2.0.1 4 | 5 | - Transparent image is stronger than ever, with 3 more ending bytes. 6 | 7 | ## 2.0.0 8 | 9 | - Maximum Stability Unlocked. 10 | 11 | ## 2.0.0-nullsafety.0 12 | 13 | - Transparent image is even stronger. It has achieved null safety. Thanks @renefloor!!! 14 | 15 | ## 1.0.0 16 | 17 | - Transparent image is strong. Therefore, 1.0. 18 | 19 | ## 0.1.0 20 | 21 | - It's a transparent image! 22 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | analyzer: 2 | strong-mode: true 3 | # exclude: 4 | # - path/to/excluded/files/** 5 | 6 | # Lint rules and documentation, see http://dart-lang.github.io/linter/lints 7 | linter: 8 | rules: 9 | - cancel_subscriptions 10 | - hash_and_equals 11 | - iterable_contains_unrelated_type 12 | - list_remove_unrelated_type 13 | - test_types_in_equals 14 | - unrelated_type_equality_checks 15 | - valid_regexps 16 | -------------------------------------------------------------------------------- /lib/transparent_image.dart: -------------------------------------------------------------------------------- 1 | library transparent_image; 2 | 3 | import 'dart:typed_data'; 4 | 5 | final Uint8List kTransparentImage = new Uint8List.fromList([ 6 | 0x89, 7 | 0x50, 8 | 0x4E, 9 | 0x47, 10 | 0x0D, 11 | 0x0A, 12 | 0x1A, 13 | 0x0A, 14 | 0x00, 15 | 0x00, 16 | 0x00, 17 | 0x0D, 18 | 0x49, 19 | 0x48, 20 | 0x44, 21 | 0x52, 22 | 0x00, 23 | 0x00, 24 | 0x00, 25 | 0x01, 26 | 0x00, 27 | 0x00, 28 | 0x00, 29 | 0x01, 30 | 0x08, 31 | 0x06, 32 | 0x00, 33 | 0x00, 34 | 0x00, 35 | 0x1F, 36 | 0x15, 37 | 0xC4, 38 | 0x89, 39 | 0x00, 40 | 0x00, 41 | 0x00, 42 | 0x0A, 43 | 0x49, 44 | 0x44, 45 | 0x41, 46 | 0x54, 47 | 0x78, 48 | 0x9C, 49 | 0x63, 50 | 0x00, 51 | 0x01, 52 | 0x00, 53 | 0x00, 54 | 0x05, 55 | 0x00, 56 | 0x01, 57 | 0x0D, 58 | 0x0A, 59 | 0x2D, 60 | 0xB4, 61 | 0x00, 62 | 0x00, 63 | 0x00, 64 | 0x00, 65 | 0x49, 66 | 0x45, 67 | 0x4E, 68 | 0x44, 69 | 0xAE, 70 | 0x42, 71 | 0x60, 72 | 0x82, 73 | ]); 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2018 Brian Egan 3 | 4 | Permission is hereby granted, free of charge, to any 5 | person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the 7 | Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, 9 | sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do 11 | so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall 14 | be included in all copies or substantial portions of 15 | the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # transparent_image 2 | 3 | A simple transparent image. Represented as a Uint8List, which was originally 4 | extracted from the Flutter codebase (was private in the test package). 5 | 6 | It's a silly, simple library, but I found I needed transparent images in a few 7 | projects and found this is the simplest way to represent it :) 8 | 9 | ## Usage 10 | 11 | This package exports one constant: `kTransparentImage`. 12 | 13 | ### Image Widget 14 | 15 | Displays the transparent image. 16 | 17 | ```dart 18 | Image.memory(kTransparentImage); 19 | ``` 20 | 21 | ### ImageProvider 22 | 23 | ```dart 24 | MemoryImage(kTransparentImage); 25 | ``` 26 | 27 | ### FadeInImage Widget 28 | 29 | A more useful example, and the reason I originally extracted this from the 30 | Flutter codebase! 31 | 32 | A [complete 33 | example](https://flutter.dev/docs/cookbook/images/fading-in-images#in-memory) 34 | can be seen on the Flutter website. 35 | 36 | ```dart 37 | FadeInImage.memoryNetwork( 38 | placeholder: kTransparentImage, 39 | image: 'https://picsum.photos/250?image=9', 40 | ), 41 | ); 42 | ``` 43 | 44 | ## Contributors 45 | 46 | * Flutter team 47 | * Brian Egan 48 | --------------------------------------------------------------------------------