-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.dart
49 lines (40 loc) · 1.73 KB
/
example.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
import 'package:mallorca_transit_services/src/api/departures.dart';
import 'package:mallorca_transit_services/src/api/route_line.dart';
import 'package:mallorca_transit_services/src/api/stations.dart';
import 'package:mallorca_transit_services/src/messaging/transit_rss.dart';
void main() async {
// Get the list of stations
final List<Station> stations = await Station.getAllStations();
print(stations);
// Get a specific station by its ID
final station = await Station.fromId(51030);
print(station);
// Get the departures info of the first station
// Limit to 5 departures
List<Departure> departures =
await Departures.getDepartures(stationCode: 51030, numberOfDepartures: 5);
print(departures);
// Get the list of lines that pass through the first station
List<RouteLine> lines = await Station.getLines(stations.first.code);
print(lines);
// Get the list of all lines
final allRoutes = await RouteLine.getAllLines();
print(allRoutes);
// Get the list of the line A42 (as an example)
final route = await RouteLine.getLine('A42');
final sublines = await Subline.getSublines(route);
print(sublines);
// Get the warning feed
final warnings = await TransitRss.getWarningFeed(Language.en);
print(warnings.items.first.title);
print(await TransitWarningScraper.scrapeAffectedLines(warnings.items.first));
print(await TransitWarningScraper.scrapeWarningDescription(
warnings.items.first));
// Get the news feed
final news = await TransitRss.getNewsFeed(Language.en);
print(news.items.first.title);
print(await NewsScraper.scrapeNewsDescription(news.items.first));
// Get the link to the PDF Timetable of line A42
final timetablePdf = await RouteLine.getPdfTimetable('A42');
print(timetablePdf);
}