Comments (5)
Hello! Does the example app work for you? Your code looks different compared to the example app. I'm not able to reproduce the issue in the example app.
I'm not familiar with Navigator.of(context).restorablePush
or DialogRoute
. From the error message it seems the problem may be with the usage of those.
from open-mail-app-flutter.
I'll give it another pass, but I was basing this code off what is now present in the Flutter API docs.
from open-mail-app-flutter.
from open-mail-app-flutter.
Ok, I've got it working (at least on Android... I don't have a Mac to test it on iOS.) I've tested with no mail app, one mail app, and two mail apps - all three cases seem to work.
Future<void> _openMailApp(BuildContext context) async {
// Android: Will open mail app or show native picker.
// iOS: Will open mail app if single mail app found.
final result = await OpenMailApp.openMailApp();
Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) => MailAppPickerDialog(
mailApps: result.options,
),
);
}
// If no mail apps found, show error
if (!result.didOpen && !result.canOpen) {
Navigator.of(context).restorablePush(_showNoMailAppsDialog);
// iOS: if multiple mail apps found, show dialog to select.
// There is no native intent/default app system in iOS so
// you have to do it yourself.
} else if (!result.didOpen && result.canOpen) {
Navigator.of(context).restorablePush(_dialogBuilder);
}
}
static Route<Object?> _showNoMailAppsDialog(
BuildContext context, Object? arguments) {
return DialogRoute<void>(
context: context,
builder: (context) {
return AlertDialog(
title: Text("Open Mail App"),
content: Text("No mail apps installed"),
actions: <Widget>[
PrimaryButton(
title: "OK",
onPressed: () {
Navigator.pop(context);
},
)
],
);
},
);
}
Invoking it looks like this:
Button(
onPressed: () => {_openMailApp(context)},
),
from open-mail-app-flutter.
I also managed to figure out how do to fix the example provided, without using my example. Notice the type next to the function, as well as the updated button.
void showNoMailAppsDialog(BuildContext context) {
showDialog<Dialog>(
context: context,
builder: (context) {
return AlertDialog(
title: Text("Open Mail App"),
content: Text("No mail apps installed"),
actions: <Widget>[
TextButton(
child: Text("OK"),
onPressed: () {
Navigator.pop(context);
},
)
],
);
},
);
}
from open-mail-app-flutter.
Related Issues (20)
- Add title to the native chooser for Android HOT 3
- conflict in pipeline HOT 2
- Error on Update Flutter 2.0.1 HOT 1
- Platform.isAndroid and Platform.isIOS while flutter test HOT 5
- Build Failed on Android HOT 1
- Problem composing new email on iOS HOT 2
- OpenMailAppPlugin.kt: (25, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. HOT 2
- Please release a new version with the updated platform: ^3.1.0 dependency HOT 1
- [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method composeNewEmailInMailApp on channel open_mail_app) HOT 4
- Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown Instance of 'ErrorDescription'. HOT 1
- Cannot change mail picker Title text (IOS 15.3.1)
- The MailAppPickerDialog that shows the email options does not match with the platform-specific alert dialog! HOT 2
- The content of emails cannot be filled automatically on Android devices, only the email app can be activated HOT 1
- Can this plugin support the attachment?
- Paypal is in Mail App Picker (Android) HOT 1
- Support for html body
- canOpenURL: failed for URL HOT 4
- problem opening the Gmail application from a Samsung S21 HOT 7
- url launcher is updated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-mail-app-flutter.