Last active
October 12, 2021 10:32
-
-
Save maherjaafar/2659dac7ff7b6545701dd38dae38778c to your computer and use it in GitHub Desktop.
Extract method
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'; | |
// Don't do this ❌ | |
class SharePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: _shareButton('https://www.hackberry.se'), | |
); | |
} | |
Widget _shareButton(String link) { | |
return 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