Senior
October 4, 2026

Spot the bug: Flutter

One snippet. Find the bug, or prove there isn't one.

dart
1import 'package:flutter/material.dart';
2
3class NavigationService {
4  static final NavigationService _instance = NavigationService._();
5  factory NavigationService() => _instance;
6  NavigationService._();
7
8  late BuildContext context;
9
10  void navigate(String route) {
11    Navigator.pushNamed(context, route);
12  }
13}
14
15class HomeScreen extends StatelessWidget {
16  
17  Widget build(BuildContext context) {
18    NavigationService().context = context;
19    return ElevatedButton(
20      onPressed: () => NavigationService().navigate('/details'),
21      child: const Text('Go'),
22    );
23  }
24}

Click the lines that carry the problem.

Your verdict

One attempt per day. The answer shows up right after.

Keep your streak

Create an account to keep your streak and track your progress.

Create an account