I have attached a basic code the switch's on change value would trigger the event like turning off data, turning phone to silent when it's in on state
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_State createState() => _State();
}
class _State extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Tutorial - googleflutter.com'),
),
body: Center(
child: Switch(
value: true,
onChanged: (value) {
setState(() {
//turn phone data to off and change phone from ring mode to silent
});
},
activeTrackColor: Colors.yellow,
activeColor: Colors.orangeAccent,
),
));
}
}
No, you cannot do what you're looking for. Since it requires telephony permission and a user's app can't have those permissions. Also, root permission is required.