I want to open the default e-mail app Inbox screen using flutter. We can use url launcher to open the email compose screen with mailto: url. But that opens the compose screen. What I want is to open the inbox screen. I can't find proper documentation for this.
How To Open Default Email App with Flutter. Open the default email client app with Flutter. Use the URL Launcher to launch an email within the default email app on your phone.
Yes, you can directly Send email from your app via SMTP using mailer plugin. You will need to ask and store user's Email, Password, SMTP port, and host and use these credentials to send emails.
You need to create a Flutter screen that contains text fields of the email. This includes a list of recipients, email subject, and email contents, along with the option to add attachments. At the end, add a button to send an email. This code contains the sample emails.
I found the answer using flutter_appavailability library. For those who are searching for the answer please see the steps below.
Add dependency | flutter_appavailability: "^0.0.21" | in pubspec.yaml (Please check the latest version in GitHub)
Add below lines in Xcode Podfile which is required for building the library in iOS
target 'Runner' do
use_frameworks! # required by simple_permission
...
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0' # required by simple_permission
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
Import below packages
import 'dart:io'; import 'package:flutter_appavailability/flutter_appavailability.dart';
Use below method
void openEmailApp(BuildContext context){
try{
AppAvailability.launchApp(Platform.isIOS ? "message://" : "com.google.android.gm").then((_) {
print("App Email launched!");
}).catchError((err) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("App Email not found!")
));
print(err);
});
} catch(e) {
Scaffold.of(context).showSnackBar(SnackBar(content: Text("Email App not found!")));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With