Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
72a3d914
Unverified
Commit
72a3d914
authored
Dec 20, 2019
by
gaaclarke
Committed by
GitHub
Dec 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a code sample for replacing the image cache. (#47467)
parent
93f718b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
Flutter-Debug.xcconfig
...ples/flutter_gallery/macos/Flutter/Flutter-Debug.xcconfig
+1
-0
Flutter-Release.xcconfig
...es/flutter_gallery/macos/Flutter/Flutter-Release.xcconfig
+1
-0
image_cache.dart
packages/flutter/lib/src/painting/image_cache.dart
+37
-0
No files found.
examples/flutter_gallery/macos/Flutter/Flutter-Debug.xcconfig
View file @
72a3d914
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
examples/flutter_gallery/macos/Flutter/Flutter-Release.xcconfig
View file @
72a3d914
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
packages/flutter/lib/src/painting/image_cache.dart
View file @
72a3d914
...
...
@@ -28,6 +28,43 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB
///
/// A shared instance of this cache is retained by [PaintingBinding] and can be
/// obtained via the [imageCache] top-level property in the [painting] library.
///
/// {@tool sample}
///
/// This sample shows how to supply your own caching logic and replace the
/// global [imageCache] varible.
///
/// ```dart
/// /// This is the custom implementation of [ImageCache] where we can override
/// /// the logic.
/// class MyImageCache extends ImageCache {
/// @override
/// void clear() {
/// print("Clearing cache!");
/// super.clear();
/// }
/// }
///
/// class MyWidgetsBinding extends WidgetsFlutterBinding {
/// @override
/// ImageCache createImageCache() => MyImageCache();
/// }
///
/// void main() {
/// // The constructor sets global variables.
/// MyWidgetsBinding();
/// runApp(MyApp());
/// }
///
/// class MyApp extends StatelessWidget {
/// @override
/// Widget build(BuildContext context) {
/// return Container();
/// }
/// }
/// ```
/// {@end-tool}
class
ImageCache
{
final
Map
<
Object
,
_PendingImage
>
_pendingImages
=
<
Object
,
_PendingImage
>{};
final
Map
<
Object
,
_CachedImage
>
_cache
=
<
Object
,
_CachedImage
>{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment