import 'package:http/http.dart' as http;
Future<void> fetchData() async {
final url = 'https://api.example.com/data';
try {
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
print('Data fetched successfully');
print('Response body: ${response.body}');
} else if (response.statusCode == 404) {
print('Requested data was not found');
} else {
print('Unexpected status code: ${response.statusCode}');
}
} catch (e) {
print('Error fetching data: $e');
}
}
void main() {
fetchData();
}