Skip to content

Instantly share code, notes, and snippets.

@maherjaafar
Last active October 12, 2021 10:32
Show Gist options
  • Save maherjaafar/2659dac7ff7b6545701dd38dae38778c to your computer and use it in GitHub Desktop.
Save maherjaafar/2659dac7ff7b6545701dd38dae38778c to your computer and use it in GitHub Desktop.
Extract method
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