How to restart app with button in flutter - flutter

I have a setting screen, when I change FontFamily it needs to restart the app to change all app fonts, And it restarts after the app closed, but I want to restart the app with a button instead of closing the app. does there any way to do this ?

The best solution... using "Restart App" module
Instal from your teminal:
flutter pub add restart_app
Import from your dart file:
import 'package:restart_app/restart_app.dart';
Call "Restart App" from your Button:
onPressed: () {
Restart.restartApp();}
Have a nice day...

Use this package https://pub.dev/packages/flutter_phoenix and call Phoenix.rebirth(context); when you want to reload the app

I have implemented the https://pub.dev/packages/flutter_phoenix package in my app, to restart the app wrap widget with Phoenix on the line of code:
runApp(Phoenix(child: MyApp()))
wherever you want to restart the app just implement this line of code
Phoenix.rebirth(context);
hope this help

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 !!!!

Is there a way to launch notes application in flutter from button click?

I have a button in my app. On click of the button, I want the notes app in the device to get launched whether iOS or Android. I there a way around this with flutter? I haven't discovered any solution yet.
Yes there is this plugin external_app_launcher will helps you to open another app from your app by providing PackageName for Android and URLscheme for IOS external_app_launcher

Flutter show app icon badge on push notification

I'm looking for a way to show an app icon badge when a user receives a push notification.
I'm using the Firebase_messaging plugin for flutter for the handling of the push notifications and flutter_app_badger for the app icon badges.
But I want to combine the two so that the number is set on the icon without opening the app. Is it possible to make this happen? Or am I overlooking something obvious from the firebase_messaging plugin?
Sorry for the horrible explanation. I hope someone can help me with this issue.
App icon badge depends on the Application Launcher
Some of the Android Application Launcher includes this functionality by default, You can check this on Settings->Apps->Notification
Attached image
FYI
How to show notification count on app icon like Facebook?
How does Facebook add badge numbers on app icon in Android?
adding notification badge on app icon in android
My suspicion is that you have an icon that isn't compatible with the icon guidelines in your device. I suggest trying https://pub.dev/packages/flutter_launcher_icons to make icons for your device.
I think you try to create stream when run app to real time listen doc changes in Firestore. Read here How to listen for document changes in Cloud Firestore using Flutter?
And the icon can be update in background but without opening app is impossible I think.
I don't have a direct answer because I haven't encountered this issue before, but this might fix your problem
Ensure that you have defined the icon for your application properly - for flutter, here are the steps you should have:
Import the package into your pubsec.yaml file - it should be called flutter_launcher_icons: "^0.8.0" and imported under the dev-dependencies section of the pubspec.yaml file.
After the dev-dependencies section, add a new section for flutter icons as so:
flutter_icons:
ios: true
android: true
image_path_ios: "{Icon File Path}"
image_path_android: "{Icon File Path}"
Hopefully this helps, and good luck with fixing your issue!
Using https://pub.dev/packages/firebase_messaging for notifications ,
for Android Background notifications you can add this in your AndroidManifest.xml file in your application tag. And make sure you have androidlogo.png (this is example name) present in your drawable folder.
<application>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/androidlogo" />
</application>
In case of foreground notifications, you must be using Flutter Local Notifications, so you can provide the same while initializing like
var initializationSettingsAndroid = new AndroidInitializationSettings('androidlogo');
flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: onNotificationClicked);
And for application icon you can use this library https://pub.dev/packages/flutter_launcher_icons which is also suggested by answers above.
In case of iOS, your launcher icon will your notification icon.
And for display of badge icon you can use https://pub.dev/packages/flutter_app_badger. (For supported phones).
So using all this you will get both app icon with badge and notification icon as your app icon (or specified by you).
You can control the badge count from the notification payload.
If you send a notification manually from Firebase Console, you can set the badge count on Additional options step:
If you send it programmatically, add this payload (iOS example):
{"aps":{"alert":"Enter your message","badge":1,"sound":"default"}}
For more payload options, check out FCM documentation

How to remove Tabs feature

I've started my app using ionic start myApp tabs.
Now, I'd like to totally remove tabs from the app.
I tried changing startpage but it doesn't work...
Is there some kind of feature like ionic generate remove... ?
Thanks
You can't automatically remove pages with ionic CLI,
However, you can start a blank project with
ionic start myApp2 blank

How to add a shortcut to mobile homescreen in Xamarin.Forms?

How can I add a shortcut icon to mobile homescreen in Xamarin.Forms ?
I am a beginner in Xamarin and try to do this.
Edit:
Currently I don't have attached an Mac for IOS, yet
so what I want is to run only Droid for now
If you deploy your Android application via the Android play store, the shortcut will be added to the home screen automatically.
For iOS, it should get added by default when you install the app.
Add the following attribute to your Activity-class:
[Activity (MainLauncher=true)]
public class MainActivity: FormsApplicationActivity {
// ...
}
That should be all. For iOS there is no special action required.