Last active
October 12, 2021 10:34
-
-
Save maherjaafar/af3f117aca70d5817c929fa0bd8e27b2 to your computer and use it in GitHub Desktop.
Extract Widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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