Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions lib/widgets/bus_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:bluebus/services/bus_info_service.dart';
import 'package:bluebus/services/bus_repository.dart';
import 'package:flutter/material.dart';
import 'package:bluebus/widgets/dialog.dart';
import '../constants.dart';
import '../models/bus.dart';
import '../services/route_color_service.dart';
Expand Down Expand Up @@ -40,18 +41,33 @@ class _BusSheetState extends State<BusSheet> {
@override
void initState() {
super.initState();
futureBusStops = fetchNextBusStops(widget.busID);
if (currBus == null) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!context.mounted) return;

Navigator.of(context).pop();

showMaizebusOKDialog(
contextIn: context,
title: const Text("Uh Oh!"),
content: const Text("Unable to fetch bus data. Please check your internet connection and try again."),
);
});
} else {
futureBusStops = fetchNextBusStops(widget.busID);
}
}

@override
Widget build(BuildContext context) {
// There was a really weird bug where _BusSheetState would get a busID that doesn't exist so currBus would be null.
// This accounts for that.
if (currBus == null) return Text("Bus not found");
// Update: Fixed the blank text "bus not found", should

if (currBus == null) return Text("Bus Not Found");

final bus = currBus!;

debugPrint(" currBus is ${currBus?.routeId}");
return Container(
decoration: BoxDecoration(
color: getColor(context, ColorType.background),
Expand Down