flutternotificationsswipe

How can I show notification panel when swiping down


I am making a launcher in flutter and I wanted to show notification panel when swipe down on homescreen.

I am trying with flutter_local_notifications package but I cant figure out how to do it,

 GestureDetector(
     onVerticalDragDown: (details) {
     // how do launch notification panel ?
     }
 )
      

Edit:

Here is the example: https://i.sstatic.net/rJBCF.gif


Solution

  • I solved the problem by calling native method through method channel

    in your MainActivity.kt create a function to expand notification panel

    private fun expandNotif() {
            val currentApiVersion = Build.VERSION.SDK_INT
            try {
                val service = getSystemService(Context.STATUS_BAR_SERVICE)
                val statusbarManager = Class.forName("android.app.StatusBarManager")
    
                val expandMethod: Method =
                        if (currentApiVersion <= Build.VERSION_CODES.N) {
                            statusbarManager.getMethod(EXPAND_METHOD)
                        } else {
                            statusbarManager.getMethod(EXPAND_NOTIFICATIONS_PANEL_METHOD)
                        }
    
                expandMethod.invoke(service)
            } catch (e: Exception) {
                // Handle exception appropriately for your application
            }
        }
    

    Then call this function through method channel