New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
url_launcher opens mailto link with plus(+) character in subject and body #75552
Comments
@kashishkhullar |
Flutter Doctor output:flutter doctor -v[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.19041.746], locale en-IN)
• Flutter version 1.22.6 at G:\flutter_windows_v1.12.13+hotfix.5-stable\flutter
• Framework revision 9b2d32b605 (2 weeks ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at G:\Android\sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_SDK_ROOT = G:\Android\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[!] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code, 64-bit edition (version 1.52.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.19.0
[√] Connected device (1 available)
• Nokia 5 1 Plus (mobile) • PDAID18092305525 • android-arm64 • Android 10 (API 29)
! Doctor found issues in 1 category. Source code of a sample app to replicate this issue:source codeimport 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final Uri _emailLaunchUri = Uri(scheme: 'mailto', path: 'smith@example.com', queryParameters: {'subject': 'Example Subject & Symbols are allowed!'});
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: RaisedButton(
onPressed: () {
launch(_emailLaunchUri.toString());
},
child: Text("Send email"),
)),
);
}
}
URI used for this issueI have used the same code to create the URI as given in the documentation. import 'dart:core';
import 'package:url_launcher/url_launcher.dart';
final Uri _emailLaunchUri = Uri(
scheme: 'mailto',
path: 'smith@example.com',
queryParameters: {
'subject': 'Example Subject & Symbols are allowed!'
}
);
// ...
// mailto:smith@example.com?subject=Example+Subject+%26+Symbols+are+allowed%21
launch(_emailLaunchUri.toString()); Screenshots using the URI in the documentation |
Need to understand the difference between query and QueryParamters difference in uri_launcher package as
this code returns
toString returns this: code which replaces space with +
exactly what's the difference between query and queryParameters ? I think in documentation there should be clear red line to what differences are if any. else there's a bug in the |
Thanks @kashishkhullar for code sample. Seems to be happening on Android 10 devices, since it doesn't occur on 8.1.0 device I tried. flutter doctor -v
|
Similar to #73717 |
They aren't part of
Which is an invalid URI, because it contains spaces.
Which is a correctly encoded URI.
The
No, that's an invalid URI unless As for the specific issue you are having, does this happen with a different |
Without additional information, we are unfortunately not sure how to resolve this issue. Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of |
Confirming this issue This worked for us:
|
See #73717 (comment) for more details; this general issue is now tracked there. |
`Uri`'s constructor doesn't handle query parameters correctly for non-http(s) schemes, so the `mailto` example in the README is misleading. This adds a new utility method to do query string construction correctly, and updates the README to show using it and warning about the need to use it in general. If/when `Uri` is fixed to handle generic URI query parameters correctly, this utility method can be deprecated. Fixes flutter/flutter#75552 Fixes flutter/flutter#73717
`Uri`'s constructor doesn't handle query parameters correctly for non-http(s) schemes, so the `mailto` example in the README is misleading. This adds a new utility method to do query string construction correctly, and updates the README to show using it and warning about the need to use it in general. If/when `Uri` is fixed to handle generic URI query parameters correctly, this utility method can be deprecated. Fixes flutter/flutter#75552 Fixes flutter/flutter#73717
`Uri`'s constructor doesn't handle query parameters correctly for non-http(s) schemes, so the `mailto` example in the README is misleading. This updates the README to show using a simple method to work around that bug, and a warning about the need to use it. Fixes flutter/flutter#75552 Fixes flutter/flutter#73717
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
`Uri`'s constructor doesn't handle query parameters correctly for non-http(s) schemes, so the `mailto` example in the README is misleading. This updates the README to show using a simple method to work around that bug, and a warning about the need to use it. Fixes flutter/flutter#75552 Fixes flutter/flutter#73717
`Uri`'s constructor doesn't handle query parameters correctly for non-http(s) schemes, so the `mailto` example in the README is misleading. This updates the README to show using a simple method to work around that bug, and a warning about the need to use it. Fixes flutter/flutter#75552 Fixes flutter/flutter#73717
Steps to Reproduce
Code
Expected results:
Gmail app compose page opens with required body and subject having space separated words
Actual results:
Gmail app compose page opens with required body and subject having "+" separated words
Screenshot
The text was updated successfully, but these errors were encountered: