Skip to content

Commit

Permalink
Fix some exceptions causing Flutter asking to demangle stacktraces
Browse files Browse the repository at this point in the history
fixes #1874
  • Loading branch information
rrousselGit committed Aug 27, 2023
1 parent 3fd2e77 commit 594c0b5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/flutter_riverpod/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.0
stack_trace: ^1.11.1
30 changes: 30 additions & 0 deletions packages/flutter_riverpod/test/throw_with_stacktrace_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/src/internals.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:stack_trace/stack_trace.dart';

void main() {
testWidgets('Flutter does not ask to demangle stacktraces', (tester) async {
final previousErrorHandler = FlutterError.onError;
final stacks = <StackTrace?>[];

FlutterError.onError = (details) => stacks.add(details.stack);
await tester.pumpWidget(
MaterialApp(
home: Consumer(
// ignore: invalid_use_of_internal_member
builder: (context, ref, child) => throwErrorWithCombinedStackTrace(
StateError('Hello world'),
StackTrace.current,
),
),
),
);
FlutterError.onError = previousErrorHandler;

expect(
stacks,
everyElement(isNot(anyOf(isA<Chain>(), isA<Trace>()))),
);
});
}
4 changes: 4 additions & 0 deletions packages/riverpod/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased patch

- Fix some exceptions causing Flutter asking to demangle stacktraces (#1874)

## 2.3.7 - 2023-08-16

- Added support for state_notifier 1.0.0
Expand Down
1 change: 1 addition & 0 deletions packages/riverpod/lib/src/internals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export 'notifier.dart';
export 'provider.dart';
export 'result.dart';
export 'run_guarded.dart';
export 'stack_trace.dart';
export 'state_notifier_provider.dart';
export 'state_provider.dart';
export 'stream_provider.dart';
2 changes: 1 addition & 1 deletion packages/riverpod/lib/src/stack_trace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Never throwErrorWithCombinedStackTrace(Object error, StackTrace stackTrace) {
...Chain.forTrace(stackTrace).traces,
]).foldFrames((frame) => frame.package == 'riverpod');

Error.throwWithStackTrace(error, chain);
Error.throwWithStackTrace(error, chain.toTrace().vmTrace);
}

0 comments on commit 594c0b5

Please sign in to comment.