androidflutterpluginsprogressdialog

How to display new android progress dialog in flutter plugin?


I am building flutter plugin and try to show native progress dialog with the code below.

ProgressDialog progressDialog =new ProgressDialog(context);
progressDialog.setTitle("Downloading");
progressDialog.setMessage("Please wait while downloading map");
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.show();   

And the dialog is displaying as below.

enter image description here

What I am expecting is default new android dialog when we create native android project like below.

enter image description here

What are the changes I need to do to make it work?

[Update] This is the default AndroidManifest.xml code

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.map_plugin">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
</manifest>

I have added application tag and added several style to this but none work

<application android:theme="@android:style/Theme.Material.Light.DarkActionBar"></application>   

Solution

  • In your styles.xml file

    <style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorAccent">@color/colorPrimary</item>
    </style>
    

    And to use it:

    ProgressDialog progressDialog = new ProgressDialog(context, R.style.MyAlertDialogStyle);
    progressDialog.setTitle("Downloading");
    progressDialog.setMessage("Please wait while downloading map");
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();  
    

    Hope this will help you to achieve this