Create a button to open another app in Flutter - flutter

I would like to create a simple app in Flutter that contains for example 3 button , the event onPressed in the button should open another external app , is that possible in Flutter and how should I proceed?

You can use Column/Row to create your buttons. And after that you can simply use a RaisedButton like this:
ElevatedButton(
onPressed: () {
// use android_intent package to open other app
final intent = AndroidIntent(package: "com.android.facebook", action: "action_view");
intent.launch();
},
child: Text("Open Facebook")
)
It's easy to do it in Android using android_intent_plus and for iOS you can do it natively, this will help you.

In my case action: "action_view" caused app selection dialog getting opened. We can open specific component using below.
You can try android_intent library for launching external app. Documentation has some sample codes.
You may use sample code below.
var map={"AuthParams":authParam};
var intent=AndroidIntent(package:"in.app",arguments: map,componentName: "in.app.ui.splash.SplashActivity",/*action: "action_view"*/);
await intent.launch();

Related

How to test if a button is pressed and how to use the console in Flutter (AndroidStudio)

I am trying to test if a button works in a flutter app.
If I was developing an Android native app, I'd make use of Log.i to print a message in the Logcat.
I want to the same exact thing in flutter.
What I've tried so far:
debugPrint
print
to import 'dart:developer' package to make use of the log function
Apart from this problem, I cannot open the console in AndroidStudio.
Here's a screenshot taken after looking fot the coslone in the search bar:
enter image description here
Any help would be appreciated !!!!
Hey there,
I am trying to test if a button works in a flutter app.
If I was developing an Android native app, I'd make use of Log.i to print a message in the Logcat.
I want to the same exact thing in flutter.
What I've tried so far:
debugPrint ...
print('BUTTON CLICKED')
import 'dart:developer' as logDev; onPressed: () => logDev.log('BUTTON CLICKED', name: 'FAB -> ')
Apart from this problem, I cannot open the console in AndroidStudio.
Here's a screenshot taken after looking fot the coslone in the search bar:
enter image description here
Any help would be appreciated !!!!

Flutter Web: Right click -> Browser Context Menu -> Open Link in New Tab

I have a basic website using GetX for navigation. I have inkwells with ontap functions which navigate to a new view. Right now, if you right click these buttons there is no "open link in new tab/window", "save link as" or "copy link address".
Is there any way to get this functionality for Flutter Web?
Edit:
Since Flutter version 2.10, you no longer need to switch to channel beta for this.
Maybe I'm answering this late, but this may help someone in the future.
At the moment of writing this it is possible to be done, it is bugged on the stable channel, but it works perfectly on channel beta.
Just switch to channel beta:
flutter channel beta
flutter upgrade
Then follow this instructions to add url_launcher dependency to your project and import this package wherever you want to use it:
import 'package:url_launcher/link.dart';
And finally wrap any widget with this:
Link(
uri: Uri.parse('www.google.com'),
builder: (context, function) {
return InkWell(
onTap: () => print('Do something'),
child: Text('Right clickable text')
);
});

How to get a list of sound notifications?

I'm building an app where the users can choose the notification sounds inside the app.
The app would display a List of all notification sound that are inside the smartphone.
The Question:
How can I get a list of all notification sounds from the users phone, so the user can choose the preferable sound?
Is there any package in pub.dev or any way to do this (Android & iOS)?
Currently, it is not extensively available. But there is a work around, and that is:
Have a button
On press of that, open up your Sound and Vibration Settings.
Let the user choose from there itself
For that you can use app_settings package.
This is simple representation of how you can open up your location settings on press of a button
Widget build(BuildContext context) {
return Row(
children: <Widget>[
RaisedButton(
onPressed: AppSettings.openLocationSettings(), // here is the magic
child: Text('Open Location Settings'),
),
],
);
}
Consider this as an option. If you don't find anything, you can come back to it, and make use of it :)
First thing there is no plugins available which are fit into your requirement.
For iOS & Android, It is mandatory to keep sound file inside your project to play custom sound when notification received.
You need to get a list of the available sound file inside your project and load it to the widget.
Thanks.

How to Tap on native iOS popup to allow Notifications. (Flutter Integration Test)

Flutter Driver code has to tap on the native "Allow" button to continue and simulate the correct user behaviour.
See this screenshot. Native iOS popup before app starts - Allow Notifications
App has not yet completely started and is waiting for this tap.
How does one get the driver to tap on the native iOS popup?
Any suggestions and ideas are welcome.
Here is the code for one attempt to wait for the app before continuing with other tests; it just awaits indefinitely:
setUpAll(() async {
driver = await FlutterDriver.connect();
await driver.waitUntilFirstFrameRasterized();
});
Here is another attempt at finding the word "Allow" in the popup and tapping on it:
test('Allow app to send Notifications.', () async {
final allow = find.byTooltip("Allow");
await delay(750);
await driver.tap(allow);
});
It does not find the word.
The issue is probably that Flutter Driver is not aware of the iOS native popup.
Other tests are very simple once in the app, for example, to tap on fields, enter text, scroll pages, etc.
Any ideas on how to do this?
Unfortunately this feature is currently not possible. Flutter Driver can't interact with native elements (v1.20.4).
https://github.com/flutter/flutter/issues/34345
https://github.com/flutter/flutter/issues/12561

How can create Google TTS button flutter?

I found this code but I need help turning it to button
when I clicked button speech hello world.
https://pub.dartlang.org/packages/flutter_tts#-example-tab-
This plugin requires Android SDK 21+, so you need to change project settings first. To do that open android/app/build.gradle, and change minSdkVersion to 21.
After that everything should work just the way it's described in the documentation and your button's click handler function may look like this:
FlutterTts flutterTts = new FlutterTts();
await flutterTts.speak("Hello World");