import 'package:flutter/services.dart'; import 'package:permission_handler/permission_handler.dart'; class WiFiPlugin { static const MethodChannel _channel = MethodChannel("com.vanstone.WifiPlugin"); static Future requestPermissions() async { bool locationGranted = await Permission.location.request().isGranted; bool wifiGranted = await Permission.manageExternalStorage.request().isGranted; bool storeGranted = await Permission.storage.request().isGranted; return locationGranted && wifiGranted && storeGranted; } // 扫描wifi static Future startScan() async { return await _channel.invokeMethod("startScan"); } // 连接wifi static Future connect() async { return await _channel.invokeMethod("connect"); } }