Skip to content

Commit

Permalink
74 - Compartilhando Gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
robertov8 committed Aug 22, 2018
1 parent 8694f8a commit 29e50b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ui/gif_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:share/share.dart';

class GifPage extends StatelessWidget {
GifPage(this._gifData);
Expand All @@ -12,6 +13,13 @@ class GifPage extends StatelessWidget {
appBar: AppBar(
title: Text(_gifData['title']),
backgroundColor: Colors.black,
actions: <Widget>[
IconButton(
icon: Icon(Icons.share),
onPressed: () {
Share.share(_gifData['images']['fixed_height']['url']);
})
],
),
body: Center(
child: Image.network(_gifData['images']['fixed_height']['url']),
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:share/share.dart';

import 'gif_page.dart';

Expand Down Expand Up @@ -64,6 +65,9 @@ class _HomePageState extends State<HomePage> {
builder: (context) =>
GifPage(snapshot.data['data'][index])));
},
onLongPress: () {
Share.share(snapshot.data['data'][index]['images']['fixed_height']['url']);
},
);
} else {
return Container(
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.29.0+1"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.3"
shelf:
dependency: transitive
description:
Expand Down Expand Up @@ -368,3 +375,4 @@ packages:
version: "2.1.13"
sdks:
dart: ">=2.0.0-dev.52.0 <=2.0.0-dev.58.0.flutter-f981f09760"
flutter: ">=0.1.4 <2.0.0"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
share: ^0.5.3

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 29e50b6

Please sign in to comment.