package Ġflutter . mo um . hardware _ buttons Ċ Ċ import Ġandroid . app . Activity Ċ import Ġio . flutter . plugin . common . Event Channel ĊĊ Ċ class ĠVolume Button Stream Handler ( private Ġval Ġactivity : ĠActivity ): ĠEvent Channel . Stream Handler Ġ{ ĊĠĠĠ Ġprivate Ġval Ġapplication Ġ= Ġactivity . application ĊĠĠĠ Ġprivate Ġvar Ġstream Sink : ĠEvent Channel . Event Sink ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġval Ġvolume Button Listener Ġ= Ġobject : ĠHardware Buttons Watcher Manager . Volume Button Listener Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Volume Button Event ( event : ĠHardware Buttons Watcher Manager . Volume Button Event ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstream Sink ?. success ( event . value ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Listen ( args : ĠAny ?, Ġsink : ĠEvent Channel . Event Sink ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . stream Sink Ġ= Ġsink ĊĠĠĠĠĠĠĠ ĠHardware Buttons Watcher Manager . getInstance ( application , Ġactivity ). add Volume Button Listener ( volume Button Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġthis Ġfunction Ġdoesn 't Ġactually Ġget Ġcalled Ġby Ġflutter Ġframework Ġas Ġof Ġnow : Ġ 2 0 1 9 / 1 0 / 0 2 ĊĠĠĠ Ġoverride Ġfun Ġon Cancel ( args : ĠAny ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . stream Sink Ġ= Ġnull ĊĠĠĠĠĠĠĠ ĠHardware Buttons Watcher Manager . getInstance ( application , Ġactivity ). remove Volume Button Listener ( volume Button Listener ) ĊĠĠĠ Ġ} Ċ }