| | |
| | | import 'package:file_picker/file_picker.dart'; |
| | | import 'package:flutter/material.dart'; |
| | | import 'package:fluttergamebox/common/theme.dart'; |
| | | import 'package:fluttergamebox/utils/network_info.dart'; |
| | | import 'package:fluttergamebox/utils/util.dart'; |
| | | |
| | | String _wmic(String cmd, String arg) { |
| | |
| | | return '00326-60000-00000-AA068'; |
| | | } |
| | | |
| | | /// 电脑网络信息弹窗 |
| | | /// 电脑网络信息弹窗(获取真实网络信息) |
| | | void showNetworkInfoDialog(BuildContext context) { |
| | | final lines = [ |
| | | '公网IP: 获取中...', |
| | | '地区: 中国', |
| | | '运营商: 联通', |
| | | ]; |
| | | _greenInfoDialog(context, '电脑网络信息', Icons.wifi, lines); |
| | | showDialog( |
| | | context: context, |
| | | builder: (context) => const _NetworkInfoDialog(), |
| | | ); |
| | | } |
| | | |
| | | class _NetworkInfoDialog extends StatefulWidget { |
| | | const _NetworkInfoDialog(); |
| | | @override |
| | | State<_NetworkInfoDialog> createState() => _NetworkInfoDialogState(); |
| | | } |
| | | |
| | | class _NetworkInfoDialogState extends State<_NetworkInfoDialog> { |
| | | List<String> _lines = ['正在获取网络信息...']; |
| | | |
| | | @override |
| | | void initState() { |
| | | super.initState(); |
| | | _load(); |
| | | } |
| | | |
| | | Future<void> _load() async { |
| | | final n = await getNetworkInfo(); |
| | | final lines = [ |
| | | '连接方式: ${n.connType}', |
| | | '内网IP: ${n.localIp}', |
| | | '网关: ${n.gateway}', |
| | | 'DNS: ${n.dns}', |
| | | '公网IP: ${n.publicIp}', |
| | | '地区: ${n.location}', |
| | | '运营商: ${n.isp}', |
| | | ]; |
| | | if (mounted) setState(() => _lines = lines); |
| | | } |
| | | |
| | | @override |
| | | Widget build(BuildContext context) { |
| | | return Dialog( |
| | | backgroundColor: const Color(0xFF14161F), |
| | | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)), |
| | | child: Container( |
| | | width: 420, |
| | | padding: EdgeInsets.zero, |
| | | child: Column( |
| | | mainAxisSize: MainAxisSize.min, |
| | | children: [ |
| | | // 标题栏 |
| | | Container( |
| | | height: 40, |
| | | padding: const EdgeInsets.symmetric(horizontal: 12), |
| | | decoration: BoxDecoration( |
| | | color: const Color(0xFF191C2B), |
| | | borderRadius: |
| | | const BorderRadius.vertical(top: Radius.circular(6)), |
| | | ), |
| | | child: Row( |
| | | children: [ |
| | | const Icon(Icons.wifi, size: 16, color: AppColors.textGray), |
| | | const SizedBox(width: 8), |
| | | const Text('电脑网络信息', |
| | | style: TextStyle(color: Colors.white, fontSize: 13)), |
| | | const Spacer(), |
| | | GestureDetector( |
| | | onTap: () => Navigator.pop(context), |
| | | child: const Icon(Icons.close, |
| | | size: 16, color: AppColors.textGray), |
| | | ), |
| | | ], |
| | | ), |
| | | ), |
| | | Padding( |
| | | padding: const EdgeInsets.all(20), |
| | | child: Column( |
| | | crossAxisAlignment: CrossAxisAlignment.start, |
| | | children: _lines |
| | | .map((l) => Padding( |
| | | padding: const EdgeInsets.symmetric(vertical: 3), |
| | | child: Text(l, |
| | | style: const TextStyle( |
| | | color: Color(0xFF33FF66), |
| | | fontSize: 13, |
| | | fontFamily: 'Consolas')), |
| | | )) |
| | | .toList(), |
| | | ), |
| | | ), |
| | | ], |
| | | ), |
| | | ), |
| | | ); |
| | | } |
| | | } |
| | | |
| | | void _greenInfoDialog( |