Skip to content

Commit

Permalink
4.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Drawner committed Apr 17, 2024
1 parent 3dd9d5a commit 58c172c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## 4.13.0
April 15, 2024
- catchError() takes FlutterErrorDetails parameters
- snapshot.stackTrace in _futureBuilder()

## 4.12.0
March 17, 2024
- Deprecated getter, startState. Use getter firstState instead
Expand Down
31 changes: 23 additions & 8 deletions lib/state_extended.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>
bool _setStateRequested = false;

/// This is the 'latest' State being viewed by the App.
bool get isEndState => this == endState;
bool get isEndState => this == lastState;

/// Asynchronous operations must complete successfully.
@override
Expand Down Expand Up @@ -2076,11 +2076,9 @@ mixin FutureBuilderStateMixin on State {
//
} else if (snapshot.hasError) {
//
final exception = snapshot.error!;

errorDetails = FlutterErrorDetails(
exception: exception,
stack: exception is Error ? exception.stackTrace : null,
exception: snapshot.error!,
stack: snapshot.stackTrace,
library: 'state_extended.dart',
context: ErrorDescription('Error in FutureBuilder'),
);
Expand Down Expand Up @@ -2622,14 +2620,31 @@ abstract class AppStateX<T extends StatefulWidget> extends StateX<T>
bool _inErrorRoutine = false;

/// Catch and explicitly handle the error.
void catchError(Exception? ex) {
void catchError(
Exception? ex, {
StackTrace? stack,
String? library,
DiagnosticsNode? context,
IterableFilter<String>? stackFilter,
InformationCollector? informationCollector,
bool? silent,
}) {
if (ex == null) {
return;
}

/// If a tester is running. Don't handle the error.
if (WidgetsBinding.instance is WidgetsFlutterBinding) {
FlutterError.onError!(FlutterErrorDetails(exception: ex));
//
FlutterError.onError!(FlutterErrorDetails(
exception: ex,
stack: stack,
library: library ?? '',
context: context,
stackFilter: stackFilter,
informationCollector: informationCollector,
silent: silent ?? false,
));
}
}

Expand Down Expand Up @@ -3010,7 +3025,7 @@ mixin RootState {
AppStateX? get rootState => RootState._rootStateX;

/// Returns the 'latest' context in the App.
BuildContext? get lastContext => rootState?.endState?.context;
BuildContext? get lastContext => rootState?.lastState?.context;

/// This is of type Object allowing you
/// to propagate any class object you wish down the widget tree.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: state_extended
description: This class extends the capabilities of Flutter's State class and includes a controller.
version: 4.12.0
version: 4.13.0
homepage: https://www.andrioussolutions.com
repository: https://github.com/AndriousSolutions/state_extended

Expand Down

0 comments on commit 58c172c

Please sign in to comment.