TKK_E32210053/lib/history_page.dart

77 lines
2.3 KiB
Dart

// import 'package:flutter/material.dart';
// import 'package:shared_preferences/shared_preferences.dart';
// import 'package:url_launcher/url_launcher.dart'; // Import library untuk membuka URL
// class HistoryPage extends StatefulWidget {
// @override
// _HistoryPageState createState() => _HistoryPageState();
// }
// class _HistoryPageState extends State<HistoryPage> {
// String _deviceIp = 'Loading...';
// @override
// void initState() {
// super.initState();
// _loadDeviceIp();
// // Simulate checking the connected device's IP
// _checkConnectedDevice();
// }
// Future<void> _loadDeviceIp() async {
// final prefs = await SharedPreferences.getInstance();
// setState(() {
// _deviceIp = prefs.getString('deviceIp') ?? 'No device connected';
// });
// }
// Future<void> _saveDeviceIp(String ip) async {
// final prefs = await SharedPreferences.getInstance();
// await prefs.setString('deviceIp', ip);
// setState(() {
// _deviceIp = ip;
// });
// }
// // This is a placeholder for your actual method to get the connected device's IP
// Future<void> _checkConnectedDevice() async {
// // Replace this with actual logic to get the IP from ESP32
// String newIp = '192.168.0.10'; // Example IP address
// // Assume the device is connected and the IP is different
// _saveDeviceIp(newIp);
// }
// // Method untuk membuka halaman web dengan alamat IP
// void _openWebPage() async {
// String url = 'http://$_deviceIp'; // Membuat URL dengan alamat IP
// if (await canLaunch(url)) { // Memeriksa apakah URL dapat dibuka
// await launch(url); // Membuka URL di browser
// } else {
// throw 'Could not launch $url'; // Melempar pengecualian jika URL tidak dapat dibuka
// }
// }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: Text('Riwayat'),
// ),
// body: Center(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text('IP Address: $_deviceIp'),
// SizedBox(height: 20),
// RaisedButton(
// onPressed: _openWebPage,
// child: Text('Buka Halaman Web'),
// ),
// ],
// ),
// ),
// );
// }
// }