// 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 { // String _deviceIp = 'Loading...'; // @override // void initState() { // super.initState(); // _loadDeviceIp(); // // Simulate checking the connected device's IP // _checkConnectedDevice(); // } // Future _loadDeviceIp() async { // final prefs = await SharedPreferences.getInstance(); // setState(() { // _deviceIp = prefs.getString('deviceIp') ?? 'No device connected'; // }); // } // Future _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 _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: [ // Text('IP Address: $_deviceIp'), // SizedBox(height: 20), // RaisedButton( // onPressed: _openWebPage, // child: Text('Buka Halaman Web'), // ), // ], // ), // ), // ); // } // }