Skip to content

Commit

Permalink
improve base docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-virkus committed Jan 19, 2021
1 parent adb70ee commit 56bf8d6
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,54 @@ Originally motivated by creating a [Flutter email app](https://github.com/enough

## Getting Started

1. Create a `MediaProvider`, e.g.
* `UrlMediaProvider('funny.png', 'image/png', 'https://domain.com/resources/funny.png')`
* `AssetMediaProvider('funny.png', 'image/png', 'stuff/funny.png')`
1. `import 'package:enough_media/enough_media.dart';`
2. Create a `MediaProvider`, e.g.
* `UrlMediaProvider('funny.png', 'image/png', 'https://domain.com/resources/funny.png')`,
* `AssetMediaProvider('funny.png', 'image/png', 'stuff/funny.png')`, or
* `MemoryMediaProvider('funny.png', 'image/png', data)` // data is a `Uint8List`
2. Either build a `PreviewMediaWidget` or an `InteractiveMediaWidget`.
3. Done :-)
3. Either build a `PreviewMediaWidget` or an `InteractiveMediaWidget`.
4. Done :-)

## Example
```dart
import 'package:enough_media/enough_media.dart';
import 'dart:typed_data';
import 'package:flutter/material.dart';
/// Preview media.
Widget buildPreview(String name, String mimeType, Uint8List data) {
final mediaProvider = MemoryMediaProvider(name, mimeType, data);
return PreviewMediaWidget(
mediaProvider: mediaProvider,
);
}
/// Provide interactive media, typically for near-fullscreen experiences:
Widget buildInteractive(String name, String mimeType, Uint8List data) {
final mediaProvider = MemoryMediaProvider(name, mimeType, data);
return InteractiveMediaWidget(
mediaProvider: mediaProvider,
);
}
/// Preview media and let enough_media move to the interactive experience with a Hero-based animation:
Widget buildPreviewWithShowInteractiveDelegate(
BuildContext context, String name, String mimeType, Uint8List data) {
final mediaProvider = MemoryMediaProvider(name, mimeType, data);
return PreviewMediaWidget(
mediaProvider: mediaProvider,
showInteractiveDelegate: (media) => Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => Scaffold(body: media))),
);
}```
## API Documentation
Check out the full API documentation at https://pub.dev/documentation/enough_media/latest/
## Installation
Add this dependencies your pubspec.yaml file:
Add this dependency your pubspec.yaml file:
```
dependencies:
Expand Down

0 comments on commit 56bf8d6

Please sign in to comment.