Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No flutter framework stack trace

I used to see full stack trace when Flutter framework throw error. However since recent release, no stack track are shown other then the following message.

Full code

import 'package:flutter/material.dart';

class BtnApp extends StatelessWidget {
  final String title;

  BtnApp([this.title]);

  @override
  Widget build(BuildContext context) {
    if (title.substring(0, 1) == '/') {
      print('start with /');
    } else {
      print('other');
    }
    return new Container();
  }
}

main() {
  runApp(new BtnApp());
}

Output

Launching lib/tinker/btnapp.dart on iPhone 7 in debug mode...
Running pod install...
Running Xcode build...
Syncing files to device iPhone 7...
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞════════
The method 'substring' was called on null.
Receiver: null

When the exception was thrown, this was the stack:
════════════════════════════════════════════════════════

no stack trace here

enter image description here

like image 680
Kyaw Tun Avatar asked Jun 30 '26 05:06

Kyaw Tun


1 Answers

There might've been changes on the version that you've updated to which have caused the issue. I've tried the minimal repro you've provided on Flutter version 2.5.1 stable channel and stacktraces for the error were displayed for both Android and iOS.

As a side note, Flutter has since release null safety support and it should prevent "method was called on null" issues - which are usually caused by forgetting to initialize the object that you're trying to access.

like image 199
Omatt Avatar answered Jul 02 '26 20:07

Omatt