I would like for someone to be able to click on a button "Contact me" and for this button to open up the email client with my email in there. I am currently just using the dummy data they give me on the package url_launcher 5.4.11.
This work properly when my url is 'https://flutter.dev'; but doesn't work when I try to enter a custom Supported URL scheme for sending an email.
The error I am getting is "Unhandled Exception: Could not launch smith@example.org?subject=Terra%20Tarot%20Question%20or%20Feedback #0 _launchURL (package:tarotcards/screens/support.dart:11:5) "
I read somewhere that it's not possible to call mail app on the iOS emulator. Is this true?
The issue is with my url in the _launchURL() method. If you can help me fix this, that would be much appreciated. Thanks so much!
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
_launchURL() async {
const url = 'mailto:smith@example.org?subject=News&body=New%20plugin';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
class Support extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
Image.asset('images/skull.png'),
Container(
padding: EdgeInsets.fromLTRB(0, 20.0, 0, 10.0),
child: Text(
'Need some help?',
style: TextStyle(
color: Colors.white,
fontFamily: 'Opensans',
fontSize: 25.0,
fontWeight: FontWeight.bold),
),
),
Container(
padding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 0.0),
child: Text(
'Experiencing bugs? Want to request a feature?'
'Feel free to get in touch with me.'
' ~Adriana',
style: TextStyle(
color: Colors.white,
letterSpacing: 0.5,
height: 1.5,
fontFamily: 'Opensans',
fontSize: 16.0,
fontWeight: FontWeight.normal),
),
),
SizedBox(
height: 40.0,
),
ButtonTheme(
//TODO:// make button #1 work!
minWidth: 300.0,
child: RaisedButton(
child: Text('CONTACT ME'),
padding: EdgeInsets.all(10.0),
textColor: Colors.white,
color: Color(0XFFeb1555),
onPressed: _launchURL,
),
),
SizedBox(
height: 40.0,
),
ButtonTheme(
//TODO:// make button #2 work!
minWidth: 300.0,
child: RaisedButton(
child: Text('FREQUENTLY ASKED QUESTIONS'),
padding: EdgeInsets.all(10.0),
textColor: Colors.black,
color: Colors.white,
onPressed: () {
print('second button tapped');
},
),
),
SizedBox(
height: 150.0,
),
FlatButton(
child: Text(
'Terms of Service & Privacy Policy →',
style: TextStyle(
color: Color(0XFFeb1555),
),
),
onPressed: () {
print('privacy policy tapped');
},
),
],
),
),
);
}
}