This repository was archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathmain.dart
60 lines (52 loc) · 1.55 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:restaurantour/modules/home/views/home_view.dart';
import 'package:restaurantour/repositories/yelp_repository.dart';
import 'common/app_theme.dart';
void main() async {
runApp(const Restaurantour());
}
class Restaurantour extends StatelessWidget {
// This widget is the root of your application.
const Restaurantour({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RestauranTour',
theme: lightTheme,
home: const HomeView(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Restaurantour'),
ElevatedButton(
child: const Text('Fetch Restaurants'),
onPressed: () async {
final yelpRepo = YelpRepository();
try {
final result = await yelpRepo.getRestaurants();
if (result != null) {
print('Fetched ${result.restaurants!.length} restaurants');
} else {
print('No restaurants fetched');
}
} catch (e) {
print('Failed to fetch restaurants: $e');
}
},
),
],
),
),
);
}
}