Closed karimiBadr closed 4 years ago
Not Expected. Could you give a reproducible demo ?
main.dart :
import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;
import 'package:flutter_app_test/home/page.dart';
import 'package:flutter_app_test/splash/page.dart';
void main() async {
runZoned(
() async {
runApp(MyApp());
},
onError: (Object obj, StackTrace stack) {
// Catch error exception
print(obj);
print(stack);
},
);
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final AbstractRoutes routes = PageRoutes(
pages: <String, Page<Object, dynamic>>{
'/splash': SplashPage(),
'/home': HomePage(),
},
);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'MyApp',
home: routes.buildPage('/splash', <String, dynamic>{}),
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute<Object>(builder: (BuildContext context) {
return routes.buildPage(settings.name, settings.arguments);
});
},
);
}
}
view.dart (splash)
import 'package:flutter/material.dart';
import 'action.dart';
import 'state.dart';
Widget buildView(
SplashState state, Dispatch dispatch, ViewService viewService) {
return Scaffold(
body: Center(
child: RaisedButton(
child: Text('throw Exception'),
onPressed: () {
throw Exception('error');
},
),
),
);
}
when i click 'throw exception' button the onError method inside runZoned is not triggered !!
thank you @zjuwjf
it works fine in release mode ! Thx
I can't use catcher library (https://pub.dev/packages/catcher), because fish-redux not exposing exceptions even when i use runZoned !!