I have a sloppy way I do it on 8.1 that uses Automagic and the volume key shortcut in Accessibility Settings. Tasker probably works too.
Turn the shortcut on, select a service. I selected a launcher I don't use. Note that this toggles the accessibility features of an app, so don't use something that needs this. Click to enable it on lockscreen.
Now when you hold both volume buttons for 3 seconds, the system notifies you the service has been toggled. Finally I have a flow in Automagic that triggers when this pops up and from there toggle the flashlight. It even works when locked IF the screen is on.
I use a similar method to customize the Active Edge thing.
Locked on Verizon. Have to be creative
