Skip to content

Instantly share code, notes, and snippets.

@maherjaafar
Last active October 12, 2021 10:34
Show Gist options
  • Save maherjaafar/af3f117aca70d5817c929fa0bd8e27b2 to your computer and use it in GitHub Desktop.
Save maherjaafar/af3f117aca70d5817c929fa0bd8e27b2 to your computer and use it in GitHub Desktop.
Extract Widget
import 'package:flutter/material.dart';
import 'package:share/share.dart';
// Instead, do this ✅
class SharePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: ShareButton(link:'https://www.hackberry.se'),
);
}
}
class ShareButton extends StatelessWidget {
const ShareButton(this.link) : super(key: key);
final String link;
@override
Widget build(BuildContext context) => ElevatedButton(
onPressed: () {
Share.share(link);
},
child: const Text('Share'),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment