UnHandled Exception : Unable to capture the error - flutter

I am trying to use Firebase Auth with Flutter. Below is my code.
login_screen.dart
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
color: blackShadeColor,
child: Text("Login",
style: GoogleFonts.poppins(
textStyle: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 16))),
onPressed: () {
_loginScreenController
.login(
context: context,
email: _emailController.text,
password: _passwordController.text)
.catchError((error) {
print(error);
});
},
),
login_screen_controller.dart
class LoginScreenController {
/**
* Login Function
*/
Future<void> login({BuildContext context, String email, String password}) async {
FirebaseAuthService firebaseAuthService = FirebaseAuthService();
firebaseAuthService.signInWithEmail(email, password).then(((value){})).catchError((onError){
throw onError;
});
}
}
firebase_auth_service.dart
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class FirebaseAuthService with ChangeNotifier {
//Sign in with username and password
Future<void> signInWithEmail(String email, String password) async {
FirebaseAuth auth = FirebaseAuth.instance;
try {
UserCredential userCredential = await auth.signInWithEmailAndPassword(
email: email, password: password);
User user = userCredential.user;
if (user != null) {
print("Sign in success: " + user.email);
} else {
print("sign in failed");
throw Exception(
"Sign in Failed. Please check your email and password again");
}
} catch (e) {
print(e.toString());
throw (e);
} finally {
//notifyListeners();
}
}
}
If there is an error, like wrong password, wrong email or something, the firebase throws an error. The issue is my attempts to catch that error is not working as expected. Instead I end up with Unhandled exception. This is the error I get.
I/flutter (18418): [firebase_auth/invalid-email] The email address is badly formatted.
E/flutter (18418): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: [firebase_auth/invalid-email] The email address is badly formatted.
[38;5;248mE/flutter (18418): #0 FirebaseAuthService.signInWithEmail[39;49m
package:wnenterprises/services/firebase_auth_service.dart
E/flutter (18418): <asynchronous suspension>
[38;5;248mE/flutter (18418): #1 LoginScreenController.login[39;49m
package:wnenterprises/controllers/login_screen_controller.dart
[38;5;248mE/flutter (18418): #2 _LoadingScreenState.build.<anonymous closure>[39;49m
package:wnenterprises/screens/login_screen.dart
[38;5;244mE/flutter (18418): #3 _InkResponseState._handleTap[39;49m
package:flutter/…/material/ink_well.dart
[38;5;244mE/flutter (18418): #4 _InkResponseState.build.<anonymous closure>[39;49m
package:flutter/…/material/ink_well.dart
[38;5;244mE/flutter (18418): #5 GestureRecognizer.invokeCallback[39;49m
package:flutter/…/gestures/recognizer.dart
[38;5;244mE/flutter (18418): #6 TapGestureRecognizer.handleTapUp[39;49m
package:flutter/…/gestures/tap.dart
[38;5;244mE/flutter (18418): #7 BaseTapGestureRecognizer._checkUp[39;49m
package:flutter/…/gestures/tap.dart
[38;5;244mE/flutter (18418): #8 BaseTapGestureRecognizer.acceptGesture[39;49m
package:flutter/…/gestures/tap.dart
[38;5;244mE/flutter (18418): #9 GestureArenaManager.sweep[39;49m
package:flutter/…/gestures/arena.dart
[38;5;244mE/flutter (18418): #10 GestureBinding.handleEvent[39;49m
package:flutter/…/gestures/binding.dart
[38;5;244mE/flutter (18418): #11 GestureBinding.dispatchEvent[39;49m
package:flutter/…/gestures/binding.dart
[38;5;244mE/flutter (18418): #12 RendererBinding.dispatchEvent[39;49m
package:flutter/…/rendering/binding.dart
[38;5;244mE/flutter (18418): #13 GestureBinding._handlePointerEvent[39;49m
package:flutter/…/gestures/binding.dart
[38;5;244mE/flutter (18418): #14 GestureBinding._flushPointerEventQueue[39;49m
package:flutter/…/gestures/binding.dart
[38;5;244mE/flutter (18418): #15 GestureBinding._handlePointerDataPacket[39;49m
package:flutter/…/gestures/binding.dart
[38;5;244mE/flutter (18418): #16 _rootRunUnary (dart:async/zone.dart:1206:13)[39;49m
[38;5;244mE/flutter (18418): #17 _CustomZone.runUnary (dart:async/zone.dart:1100:19)[39;49m
[38;5;244mE/flutter (18418): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)[39;49m
[38;5;244mE/flutter (18418): #19 _invoke1 (dart:ui/hooks.dart:265:10)[39;49m
[38;5;244mE/flutter (18418): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)[39;49m
E/flutter (18418):
What is really happening here?

Instead of async await, you can try the regular .then() method and use the catch error function. :
auth.signInWithEmailAndPassword(email: email, password: password).then((val){print(val);}).catchError((e){print("Exception: " + e.toString())});

Related

'instanceFactory != null': Object/factory with type UserController is not registered inside GetIt. (But it is)

I have a two apps project, I am using get_it to get the profile picture from firebase Storage
.
The problem is that in the first app the code is working perfectly and the sign in procedure finish up normally, but in this one I copied the code as it was and made the necessary changes (imports mostly) however getting the profile picture using get_it is interrupting the signing and the sign up procedure and returning this error in the console:
/flutter ( 4798): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: 'package:get_it/get_it_impl.dart': Failed assertion: line 372 pos 7: 'instanceFactory != null': Object/factory with type UserController is not registered inside GetIt.
package:get_it/get_it_impl.dart:372
E/flutter ( 4798): (Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;
E/flutter ( 4798): Did you forget to register it?)
E/flutter ( 4798): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter ( 4798): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter ( 4798): #2 _GetItImplementation._findFactoryByNameAndType
package:get_it/get_it_impl.dart:372
E/flutter ( 4798): #3 _GetItImplementation.get
package:get_it/get_it_impl.dart:393
E/flutter ( 4798): #4 _SignInPageState.build.<anonymous closure>
package:nhafeflek/…/authentication/sign_in.dart:193
E/flutter ( 4798): #5 _SignInPageState.build.<anonymous closure>
package:nhafeflek/…/authentication/sign_in.dart:190
E/flutter ( 4798): #6 _InkResponseState._handleTap
E/flutter ( 4798): #7 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:198
E/flutter ( 4798): #8 TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:613
E/flutter ( 4798): #9 BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:298
E/flutter ( 4798): #10 BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/…/gestures/tap.dart:232
E/flutter ( 4798): #11 PrimaryPointerGestureRecognizer.handleEvent
package:flutter/…/gestures/recognizer.dart:563
E/flutter ( 4798): #12 PointerRouter._dispatch
package:flutter/…/gestures/pointer_router.dart:94
E/flutter ( 4798): #13 PointerRouter._dispatchEventToRoutes.<anonymous closure>
package:flutter/…/gestures/pointer_router.dart:139
E/flutter ( 4798): #14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
E/flutter ( 4798): #15 PointerRouter._dispatchEventToRoutes
package:flutter/…/gestures/pointer_router.dart:137
E/flutter ( 4798): #16 PointerRouter.route
package:flutter/…/gestures/pointer_router.dart:123
E/flutter ( 4798): #17 GestureBinding.handleEvent
E/flutter ( 4798): #18 GestureBinding.dispatchEvent
package:flutter/…/gestures/binding.dart:425
E/flutter ( 4798): #19 RendererBinding.dispatchEvent
package:flutter/…/rendering/binding.dart:326
E/flutter ( 4798): #20 GestureBinding._handlePointerEventImmediately
package:flutter/…/gestures/binding.dart:380
E/flutter ( 4798): #21 GestureBinding.handlePointerEvent
package:flutter/…/gestures/binding.dart:344
E/flutter ( 4798): #22 GestureBinding._flushPointerEventQueue
package:flutter/…/gestures/binding.dart:302
E/flutter ( 4798): #23 GestureBinding._handlePointerDataPacket
package:flutter/…/gestures/binding.dart:285
E/flutter ( 4798): #24 _rootRunUnary (dart:async/zone.dart:1442:13)
E/flutter ( 4798): #25 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter ( 4798): #26 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter ( 4798): #27 _invoke1 (dart:ui/hooks.dart:170:10)
E/flutter ( 4798): #28 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7)
E/flutter ( 4798): #29 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
and as I already said it is registered and already working in the other app and here is my code:
My locator.dart file
import 'package:get_it/get_it.dart';
import 'package:nhafeflek/services/auth.dart';
import 'package:nhafeflek/services/storage.dart';
import 'package:nhafeflek/services/userController.dart';
var locator = GetIt.instance;
Future<void> setupServices() async {
locator.registerSingleton<AuthService>(AuthService());
locator.registerSingleton<StorageService>(StorageService());
locator.registerLazySingleton<UserController>(() => UserController());
}
My UserController.dart file:
import 'dart:io';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:nhafeflek/models/user.dart';
import 'package:nhafeflek/services/auth.dart';
import 'package:nhafeflek/services/locator.dart';
import 'package:nhafeflek/services/storage.dart';
class UserController {
late Userr _currentUser;
final AuthService _authService = locator.get<AuthService>();
final FirebaseAuth _auth = FirebaseAuth.instance;
late Future init;
final StorageService _storageService = locator.get<StorageService>();
UserController() {
init = initUser();
}
Future<Userr> initUser() async {
_currentUser = await _authService.getUser();
return _currentUser;
}
Userr get currentUser => _currentUser;
Future<void> uploadProfilePicture(File image) async {
_currentUser.avatarUrl = await _storageService.uploadFile(image);
}
Userr? _userFromFirebaseUser(User? user) {
if (user != null) {
return Userr(uid: user.uid);
} else {
return null;
}
}
Future<String> getDownloadUrl() async {
return await _storageService
.getUserProfileImageDownloadUrl(FirebaseAuth.instance.currentUser!.uid);
}
Future signInWithEmailAndPassword(String email, String password) async {
_currentUser =
await _authService.signInWithEmailAndPassword(email, password);
_currentUser = Userr(
uid: FirebaseAuth.instance.currentUser!.uid,
avatarUrl: await getDownloadUrl());
try {
UserCredential result = await _auth.signInWithEmailAndPassword(
email: email, password: password);
User barber = result.user!;
return _userFromFirebaseUser(barber);
} catch (e) {
return null;
}
}
}
My SignIn button:
ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
dynamic result = await locator
.get<UserController>()
.signInWithEmailAndPassword(email, password);
if (result == null) {
setState(() =>
error = 'Something went wrong... Please try again!');
}
}
},
style: ButtonStyle(
shadowColor:
MaterialStateProperty.all(const Color(0xff5680a7)),
backgroundColor:
MaterialStateProperty.all(const Color(0xff5680a7)),
padding: MaterialStateProperty.all(const EdgeInsets.symmetric(horizontal: 120, vertical: 15)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
side: const BorderSide(
color: Color(0xff5680a7), width: 3)))),
child: const Text(
'Sign In',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
)
)
If you need any other sample of the code don't hesitate for asking. I seek your help.

How to log out user and How to check user verify mail

I got the following problem.
When user register he will be on a page, where I show a message like check your Email account. And when user check his account and confirm his mail he automatically get to homepage. So far so good. But when user press register button an get mail and reload the page he get also inside homepage without confirm his mail.
I trie this
Future<String> signIN(String email, String password) async {
try {
UserCredential result =await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email.trim(),
password: password,
);
User user = result.user;
if(user.emailVerified){
return user.uid;
}
} on FirebaseAuthException catch (e) {
but not working.
here's my verify email page
import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:projectandroidstudiodenya/seitenleiste/homepage.dart';
class VerifyScreen extends StatefulWidget {
#override
_VerifyScreenState createState() => _VerifyScreenState();
}
class _VerifyScreenState extends State<VerifyScreen> {
final auth= FirebaseAuth.instance;
User user;
Timer timer;
#override
void initState() {
user= auth.currentUser;
user.sendEmailVerification();
timer= Timer.periodic(Duration(seconds: 5), (timer) {
checkEmailverifyed();
});
super.initState();
}
#override
void dispose() {
timer.cancel();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body:Center(
)
);
}
Future<void> checkEmailverifyed() async{
user=auth.currentUser;
await user.reload();
if(user.emailVerified){
timer.cancel();
Navigator.of(context).
pushReplacement(MaterialPageRoute(builder:(context)=> Homepage()));
}
}
}
Maybe anyone can help.
And also when user press logout button nothing happened. but when user restart the app he logged out.
here's my logout pressed method:
onPressed: () {
FirebaseAuth.instance.signOut();
FirebaseAuth.instance.signOut();Navigator.pushNamedAndRemoveUntil(context, LoginScreen.route, (route) => false);
Heres the error of the sign out:
D/FirebaseAuth(26776): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(26776): Notifying auth state listeners about a sign-out event.
E/flutter (26776): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Could not find a generator for route RouteSettings("SignIn", null) in the _WidgetsAppState.
E/flutter (26776): Make sure your root app widget has provided a way to generate
E/flutter (26776): this route.
E/flutter (26776): Generators for routes are searched for in the following order:
E/flutter (26776): 1. For the "/" route, the "home" property, if non-null, is used.
E/flutter (26776): 2. Otherwise, the "routes" table is used, if it has an entry for the route.
E/flutter (26776): 3. Otherwise, onGenerateRoute is called. It should return a non-null value for any valid route not handled by "home" and "routes".
E/flutter (26776): 4. Finally if all else fails onUnknownRoute is called.
E/flutter (26776): Unfortunately, onUnknownRoute was not set.
E/flutter (26776): #0 _WidgetsAppState._onUnknownRoute.<anonymous closure> (package:flutter/src/widgets/app.dart:1219:9)
E/flutter (26776): #1 _WidgetsAppState._onUnknownRoute (package:flutter/src/widgets/app.dart:1234:6)
E/flutter (26776): #2 NavigatorState._routeNamed (package:flutter/src/widgets/navigator.dart:4148:37)
E/flutter (26776): #3 NavigatorState.pushNamedAndRemoveUntil (package:flutter/src/widgets/navigator.dart:4391:34)
E/flutter (26776): #4 Navigator.pushNamedAndRemoveUntil (package:flutter/src/widgets/navigator.dart:2042:34)
E/flutter (26776): #5 _openSignOutDrawer.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:projectandroidstudiodenya/seitenleiste/seitenleiste.dart:188:90)
E/flutter (26776): #6 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (26776): #7 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (26776): <asynchronous suspension>
E/flutter (26776):
And the error of the sig in:
E/flutter (26776): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: The getter 'emailVerified' was called on null.
E/flutter (26776): Receiver: null
E/flutter (26776): Tried calling: emailVerified
E/flutter (26776): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter (26776): #1 AuthService.signIN (package:projectandroidstudiodenya/services/auth.dart:44:44)
E/flutter (26776): #2 _LoginScreenState._buildLoginBtn.<anonymous closure> (package:projectandroidstudiodenya/authenticate/signin.dart:170:48)
E/flutter (26776): #3 _LoginScreenState._buildLoginBtn.<anonymous closure> (package:projectandroidstudiodenya/authenticate/signin.dart:168:24)
E/flutter (26776): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:994:20)
E/flutter (26776): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (26776): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607:11)
E/flutter (26776): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296:5)
E/flutter (26776): #8 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267:7)
E/flutter (26776): #9 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
E/flutter (26776): #10 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:443:20)
E/flutter (26776): #11 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
E/flutter (26776): #12 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:288:11)
E/flutter (26776): #13 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
E/flutter (26776): #14 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
E/flutter (26776): #15 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
E/flutter (26776): #16 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
E/flutter (26776): #17 _rootRunUnary (dart:async/zone.dart:1370:13)
E/flutter (26776): #18 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (26776): #19 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (26776): #20 _invoke1 (dart:ui/hooks.dart:186:10)
E/flutter (26776): #21 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
E/flutter (26776): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)
E/flutter (26776):
My sig in method looks like that:
Future<String> signIN(String email, String password) async {
try {
if(FirebaseAuth.instance.currentUser.emailVerified) {
( await _auth.signInWithEmailAndPassword(
email: email.trim(), password: password,)).user;
// User user = result.user;
}
} on FirebaseAuthException catch (e) {
switch (e.code) {
case 'invalid-email':
{
return 'Email is not valid';
}
case 'user-disabled':
{
return 'Account is not active';
}
case 'user-not-found':
{
return 'No user found';
}
case 'wrong-password':
{
return 'wrong password';
}
default:
{
return 'Unexpected error!';
}
}
}
return null;
}
It looks different because I changed it like it was before that so I can check if maybe it was on the changes it do because it runs at this point.
You should check email verification within you're sign-in method, and if the email was verified then return instance.signInWithEmailAndPassword.
full code:
Future<String> signIN(String email, String password) async {
try {
if(FirebaseAuth.instance.currentUser.emailVerified) {
( await _auth.signInWithEmailAndPassword(
email: email.trim(), password: password,)).user;
return "success";
// User user = result.user;
}
} on FirebaseAuthException catch (e) {
switch (e.code) {
case 'invalid-email':
{
return 'Email is not valid';
}
case 'user-disabled':
{
return 'Account is not active';
}
case 'user-not-found':
{
return 'No user found';
}
case 'wrong-password':
{
return 'wrong password';
}
default:
{
return 'Unexpected error!';
}
}
}
return return "error";;
}
so every moment when signIN calling it would check email verification and if it verified it would work if it isn't it will return "error" or other problem variants, and you can listen to response so when it gives you an error you should return a snackBar, if it returns "success" then you would navigate.
Solution of logout issue:
onPressed: () {
FirebaseAuth.instance.signOut().then((){
Navigator.pushNamedAndRemoveUntil(context, LoginScreen.route (route) => false);
});

Unhandled Exception: Exception: Failed to create Register

the method name is createResgister so this is the method that returns a Future that contains a Response. ok and in there is TextEdittingController of each form i want post and the api i want to post it too
ok am having an error trying to post a register form to an apiKey code:
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:logistics_app/models/registerApi.dart';
import 'package:logistics_app/ui/dashboard_view.dart';
import 'package:logistics_app/utils/validation.dart';
import 'package:http/http.dart' as http;
import '../ui/login_view.dart';
class UserOnboardingModel extends ChangeNotifier with ValidationMixin{
TextEditingController firstController = TextEditingController();
TextEditingController lastController = TextEditingController();
TextEditingController passwordController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController phoneController = TextEditingController();
bool showPassword = true;
final formKey = GlobalKey<FormState>();
Future<RegisterModel> _futureRegister;
Future<RegisterModel> createRegister()async{
final http.Response response = await http.post(
"apiKey",
body: jsonEncode(<String, String>{
'firstName' : validateFirstName(firstController.text),
'lastName' : validateLastName(lastController.text),
'emailAddress' : validateEmail(emailController.text),
'phoneNumber' : validatePhoneNumber(phoneController.text),
'password' : validatePassword(passwordController.text)
})
);
if(response.statusCode == 201){
return RegisterModel.fromJson(json.decode(response.body));
}else{
throw Exception('Failed to create Register');
}
}
void passRegister(){
_futureRegister = createRegister();
}
void registerForm(){
FutureBuilder<RegisterModel>(
future: _futureRegister,
builder: (context, snapshot){
if(snapshot.hasData){
return Column(
children: [
Text(snapshot.data.firstName),
Text(snapshot.data.lastName),
Text(snapshot.data.emailAddress),
Text(snapshot.data.phoneNumber),
Text(snapshot.data.password)
],
);
}else if(snapshot.hasError){
return Text("${snapshot.error}");
}
return CircularProgressIndicator();
},
);
}
void togglePassword(){
showPassword = !showPassword;
notifyListeners();
}
void validateForm(){
formKey.currentState.validate();
}
void moveToLogin(context){
//go to login page
if(formKey.currentState.validate()){
Navigator.pushNamed(context, LogIn.LOG_IN_ROUTE);
}
else{
Fluttertoast.showToast(
msg: "Please Fill The Form",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 5,
backgroundColor: Colors.black,
);
}
}
void moveToDashBoardView(context){
//go to login page
if(formKey.currentState.validate()){
Navigator.push(context, MaterialPageRoute(
builder: (context) => DashboardView()
));
}
else{
Fluttertoast.showToast(
msg: "Please Fill The Form",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 5,
backgroundColor: Colors.black,
);
}
}
void moveToSignup(){
//go to sign up page
notifyListeners();
}
void moveToForgottenPassword(){
//go to forgotten password page
notifyListeners();
}
}
now this is the error am getting saying: Failed to create Register
E/flutter ( 7901): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Exception: Failed to create Register
E/flutter ( 7901): #0 UserOnboardingModel.createRegister (package:logistics_app/models/userOnboardingModel.dart:42:7)
E/flutter ( 7901): <asynchronous suspension>
E/flutter ( 7901): #1 UserOnboardingModel.passRegister (package:logistics_app/models/userOnboardingModel.dart:47:23)
E/flutter ( 7901): #2 _buildCircleAvatar.<anonymous closure>.<anonymous closure> (package:logistics_app/ui/sign_up_view.dart:241:18)
E/flutter ( 7901): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
E/flutter ( 7901): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1098:38)
E/flutter ( 7901): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
E/flutter ( 7901): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
E/flutter ( 7901): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
E/flutter ( 7901): #8 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:256:7)
E/flutter ( 7901): #9 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:158:27)
E/flutter ( 7901): #10 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
E/flutter ( 7901): #11 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter ( 7901): #12 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
E/flutter ( 7901): #13 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
E/flutter ( 7901): #14 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
E/flutter ( 7901): #15 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 7901): #16 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 7901): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 7901): #18 _invoke1 (dart:ui/hooks.dart:267:10)
E/flutter ( 7901): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
E/flutter ( 7901):

Problem with BLE module : Exception: Another scan is already in progress

I'm trying to make possible the following actions:
I run my app and when I press the "Connect" button I connect to my BLE module.
A second button allows me to disconnect from it.
The problem is that if I connect to the BLE module, and then press the disconnect button, it disconnect but I will no longer be able to connect to the BLE anymore (and I have to restart the app).
There is my code:
import 'dart:async';
import 'dart:convert' show utf8;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_blue/flutter_blue.dart';
void main() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft
]);
runApp(MainScreen());
}
class MainScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'BLUETOOTH',
debugShowCheckedModeBanner: false,
home: Home(),
theme: ThemeData.dark(),
);
}
}
class Home extends StatefulWidget {
#override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
String connectionText = "";
final String SERVICE_UUID = "4fafc201-1fb5-459e-8fcc-c5c9c331914b";
final String CHARACTERISTIC_UUID = "beb5483e-36e1-4688-b7f5-ea07361b26a8";
final String TARGET_DEVICE_NAME = "MLT-BT05";
FlutterBlue flutterBlue = FlutterBlue.instance; // * Instance de FlutterBlue
StreamSubscription<ScanResult> scanSubScription; // * StreamSubscription
BluetoothDevice targetDevice; // * Device
BluetoothCharacteristic targetCharacteristic; // * Characteristiques
#override
void initState() {
super.initState();
// startScan();
}
startScan() {
setState(() {
connectionText = "Start Scanning";
});
scanSubScription = flutterBlue.scan().listen((scanResult) {
print(scanResult.device.name.toString()); // ! TEST
if (scanResult.device.name == TARGET_DEVICE_NAME) {
print('DEVICE found');
stopScan();
setState(() {
connectionText = "Found Target Device";
});
targetDevice = scanResult.device;
connectToDevice();
}
}, onDone: () => stopScan());
}
stopScan() {
scanSubScription?.cancel();
scanSubScription = null;
}
connectToDevice() async {
if (targetDevice == null) return;
setState(() {
connectionText = "Device Connecting";
});
await targetDevice.connect();
print('DEVICE CONNECTED');
setState(() {
connectionText = "Device Connected";
});
discoverServices();
}
disconnectFromDevice() {
if (targetDevice == null) return;
targetDevice.disconnect();
setState(() {
connectionText = "Device Disconnected";
});
}
discoverServices() async {
if (targetDevice == null) return;
List<BluetoothService> services = await targetDevice.discoverServices();
services.forEach((service) {
// do something with service
if (service.uuid.toString() == SERVICE_UUID) {
service.characteristics.forEach((characteristic) {
if (characteristic.uuid.toString() == CHARACTERISTIC_UUID) {
targetCharacteristic = characteristic;
writeData("Hi there, ESP32!!");
setState(() {
connectionText = "All Ready with ${targetDevice.name}";
});
}
});
}
});
}
writeData(String data) {
if (targetCharacteristic == null) return;
List<int> bytes = utf8.encode(data);
targetCharacteristic.write(bytes);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(connectionText),
centerTitle: true,
),
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text("Connect"),
color: Colors.grey[700],
onPressed: () {
startScan();
},
),
FlatButton(
child: Text("Disconnect"),
color: Colors.grey[700],
onPressed: () {
disconnectFromDevice();
},
),
],
),
),
);
}
}
The error tells me that another scan is already in progress even though the scanSubScription is canceled and set to null once the device is connected.
The error:
I/flutter (13433): [TV] Samsung 7 Series (55)
I/flutter (13433): MLT-BT05
I/flutter (13433): DEVICE found
I/flutter (13433): DEVICE CONNECTED
E/flutter (13433): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Exception: Another scan is already in progress.
E/flutter (13433): #0 FlutterBlue.scan (package:flutter_blue/src/flutter_blue.dart:81:7)
E/flutter (13433): <asynchronous suspension>
E/flutter (13433): #1 _HomeState.startScan (package:bluetoothv8/main.dart:53:36)
E/flutter (13433): #2 _HomeState.build.<anonymous closure> (package:bluetoothv8/main.dart:140:17)
E/flutter (13433): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (13433): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (13433): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (13433): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (13433): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (13433): #8 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
E/flutter (13433): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9)
E/flutter (13433): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (13433): #11 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9)
E/flutter (13433): #12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (13433): #13 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
E/flutter (13433): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
E/flutter (13433): #15 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (13433): #16 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (13433): #17 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (13433): #18 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (13433): #19 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (13433): #20 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (13433): #21 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (13433): #22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (13433): #23 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (13433): #24 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
Instead of:
stopScan() {
scanSubScription?.cancel();
scanSubScription = null;
}
write:
stopScan() {
flutterBlue.stopScan();
scanSubScription?.cancel();
scanSubScription = null;
}
please use like this
bluetoothInstance.stopScan().then((value) {
scanSubscription.cancel();
scanBLE(); //if you need, you can start scan again
});

Flutter: version 0.2.8 breaks code that used to work

Before I update to the new version of flutter (see below) everything worked OK.
Now it does no longer work.
The following piece of code performs a "paged" load of a gridView
Could somebody tell me what has changed with the last version of Flutter and how to solve this issue ?
Many thanks
Flutter version:
flutter --version
Flutter 0.2.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision b397406561 (11 days ago) • 2018-04-02 13:53:20 -0700
Engine • revision c903c217a1
Tools • Dart 2.0.0-dev.43.0.flutter-52afcba357
Here is the code that used to work:
typedef Future<PageAnswer> ApiPageRequest(int page, int pageSize);
class MIDApi {
///
/// Returns the list of items belonging to the active profile
///
Future<PageAnswer> getItems({
int pageIndex: 0,
int pageSize: 50,
#required String sortOrder
}) async {
String url = "ItemsList/$sortOrder";
return ajaxGet(url).then((String responseBody) async {
// print(responseBody);
final Map response = json.decode(responseBody);
final _status = response["status"];
if (_status == "OK"){
// Everything is OK
Map map = json.decode(response["data"]);
List<Map> objects = map["List"];
int total = map["Total"];
return new PageAnswer(objects, total);
}
return Null;
}).catchError((){
return Null;
});
}
}
///
/// This widget is used to display a "paged" GridView
///
/// Invocation example:
/// new PagedGridView<Map>(request, widgetAdapter: adapt);
///
/// where: request could be
/// Future<List<Map>> request(int page, int pageSize) async {
/// routine to fetch the data from the server
/// }
///
/// and adapt could be:
/// Widget adapt(Map map){
/// return new MyWidget(map);
/// }
///
class PagedGridView extends StatefulWidget {
/// Abstraction for loading the data.
/// This can be anything: An API-Call,
/// loading data from a certain file or database,
/// etc. If will deliver a list of objects (of type T)
final ApiPageRequest pageRequest;
/// The number of columns per row of the grid
final int numberColumns;
/// The number of elements requested for each page
final int pageSize;
/// The number of left-over elements in list which
/// will trigger loading the next page
final int pageThreshold;
/// Used for building Widgets out of the fetched data
final WidgetAdapter<Map> widgetAdapter;
final bool reverse;
final Indexer<Map> indexer;
final Stream<Map> topStream;
/// Constructor
const PagedGridView({
Key key,
this.numberColumns: 2,
this.pageSize: 50,
this.pageThreshold: 10,
#required this.pageRequest,
#required this.widgetAdapter,
this.reverse: false,
this.indexer,
this.topStream
}): super(key: key);
#override
State<StatefulWidget> createState() {
return new PagedGridViewState();
}
}
class PagedGridViewState extends State<PagedGridView> {
/// Contains all fetched elements ready to display
List<Map> objects = [];
/// Total number of objects that could be returned
int total = -1;
/// A Future returned by loadNext() if there
/// is currently a request running
/// or null, if no request is performed
Future request;
Map<int, int> index = {};
void doSomething(){
print("I need to do something");
}
void Clear() async {
await onRefresh();
}
#override
void initState(){
super.initState();
/// At start, let's systematically try to fetch some data
this.lockedLoadNext();
if (widget.topStream != null){
widget.topStream.listen((Map t){
setState((){
this.objects.insert(0, t);
this.reIndex();
});
});
}
}
#override
Widget build(BuildContext context){
GridView listView = new GridView.builder(
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: widget.numberColumns),
itemBuilder: itemBuilder,
itemCount: objects.length,
reverse: widget.reverse
);
RefreshIndicator refreshIndicator = new RefreshIndicator(
onRefresh: onRefresh,
child: listView
);
return new NotificationListener<ListElementUpdate<Map>>(
child: refreshIndicator,
onNotification: onUpdate
);
}
Widget itemBuilder(BuildContext context, int index){
/// If we are entering the threshold zone,
/// try to fetch additional objects
if (index + widget.pageThreshold > objects.length){
notifyThreshold();
}
return widget.widgetAdapter != null ? widget.widgetAdapter(objects[index])
: new Container();
}
void notifyThreshold(){
lockedLoadNext();
}
bool onUpdate(ListElementUpdate<Map> update){
if (widget.indexer == null){
debugPrint('ListElementUpdate on un-indexed list');
return false;
}
int index = this.index[update.key];
if (index == null){
debugPrint('ListElementUpdate index not found');
return false;
}
setState((){
this.objects[index] = update.instance;
});
return true;
}
Future onRefresh() async {
this.request?.timeout(const Duration());
PageAnswer answer = await widget.pageRequest(0, widget.pageSize);
List<Map> fetched = answer.list;
total = answer.total;
setState(() {
this.objects.clear();
this.index.clear();
this.addObjects(fetched);
});
return true;
}
///
/// This routine only fetches new data, if no other request is pending
///
void lockedLoadNext() {
if (this.request == null) {
this.request = loadNext().then((x) {
this.request = null;
});
}
}
Future loadNext() async {
// If there is no need to fetch any further data, simply return
if (objects.length >= total && total != -1){
return Null;
}
int page = (objects.length / widget.pageSize).floor();
PageAnswer answer = await widget.pageRequest(page, widget.pageSize);
List<Map> fetched = answer.list;
total = answer.total;
if (mounted) {
this.setState(() {
addObjects(fetched);
});
}
}
void addObjects(Iterable<Map> objects) {
objects.forEach((Map object) {
int index = this.objects.length;
this.objects.add(object);
if (widget.indexer != null) {
this.index[widget.indexer(object)] = index;
}
});
}
void reIndex(){
this.index .clear();
if (widget.indexer!=null){
int i = 0;
this.objects.forEach((object){
index[widget.indexer(object)] == i;
i++;
});
}
}
}
Invocation code:
class ItemsPage extends StatefulWidget {
#override
_ItemsPageState createState() => new _ItemsPageState();
}
class _ItemsPageState extends State<ItemsPage> {
static final GlobalKey<PagedGridViewState> _gridKey = new GlobalKey<PagedGridViewState>();
String _path = mid.serverHttps ? "https://${mid.serverUrl}/"
: "http://${mid.serverUrl}/";
String _sortOrder;
final List<SortMethod> sortMethods = const <SortMethod>[
const SortMethod(value: 'alpha', title: "Alpha", icon: Icons.sort_by_alpha),
const SortMethod(value: 'older_first', title: "Older first", icon: Icons.autorenew),
const SortMethod(value: 'last_first', title: "Last first", icon: Icons.change_history),
];
Future<PageAnswer> request(int page, int pageSize) async {
PageAnswer answer = await mid.api.getItems(sortOrder: _sortOrder);
return answer;
}
void _handleTap(int lookId) {
print('tap:' + lookId.toString());
}
Widget adapt(Map map){
var photos = map["Photos"].split(";");
String photoName = photos[0].split("|")[0];
return new GestureDetector(
onTap: () {_handleTap(map["Id"]);},
child: new GridTile(
child: new Card(
child: new Stack(
fit: StackFit.expand,
children: <Widget>[
new Image.network(_path + photoName,
fit: BoxFit.fitHeight),
new Center(
child: new Text(
map["Title"],
textAlign: TextAlign.center,
)),
],
),
),
),
);
}
_onSortOrderChanged(String value) {
setState((){
_sortOrder = value;
_gridKey.currentState.Clear();
});
}
#override
void initState(){
super.initState();
_sortOrder = 'alpha';
}
#override
Widget build(BuildContext context) {
PagedGridView grid = new PagedGridView(
key: _gridKey,
pageRequest: request,
widgetAdapter: adapt,
numberColumns: 2,
);
DropdownButton ddl = new DropdownButton<String>(
value: _sortOrder,
items: sortMethods.map((SortMethod sort){
return new DropdownMenuItem(
value: sort.value,
child: new Row(children: <Widget>[new Icon(sort.icon), new Text(sort.title)],)
);
}).toList(),
onChanged: _onSortOrderChanged,
);
PopupMenuButton<ItemSorting> popSort = new PopupMenuButton<ItemSorting>(
icon: new Icon(Icons.sort),
itemBuilder: (BuildContext context) => <PopupMenuItem<ItemSorting>> [
const PopupMenuItem<ItemSorting>(
value: ItemSorting.alpha,
child: const Text('Sort Alpha')
),
const PopupMenuItem<ItemSorting>(
value: ItemSorting.last_first,
child: const Text('Sort Last First')
),
const PopupMenuItem<ItemSorting>(
value: ItemSorting.older_first,
child: const Text('Sort Older First')
)
],
onSelected: (ItemSorting action){
_onSortOrderChanged(action.toString().split('.')[1]);
},
);
return new Scaffold(
appBar: new AppBar(
title: new Text('My Items'),
actions: <Widget>[
popSort, //ddl,
],
),
body: new Center(
child: grid,
),
);
}
}
class SortMethod {
const SortMethod({this.title, this.icon, this.value});
final String title;
final IconData icon;
final String value;
}
Error stack:
E/flutter (15195): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (15195): type 'Future<Object>' is not a subtype of type 'FutureOr<PageAnswer>' where
E/flutter (15195): Future is from dart:async
E/flutter (15195): Object is from dart:core
E/flutter (15195): FutureOr is from dart:async
E/flutter (15195): PageAnswer is from file:///D:/Development/appli/lib/libraries/function_types.dart
E/flutter (15195):
E/flutter (15195): #0 MIDApi.getItems (file:///D:/Development/appli/lib/libraries/api.dart:35:8)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #1 _ItemsPageState.request (file:///D:/Development/appli/lib/pages/items.dart:30:39)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #2 PagedGridViewState.loadNext (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:191:38)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #3 PagedGridViewState.lockedLoadNext (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:178:22)
E/flutter (15195): #4 PagedGridViewState.initState (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:93:10)
E/flutter (15195): #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
E/flutter (15195): #6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #8 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #9 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4637:14)
E/flutter (15195): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #20 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #21 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #22 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3938:11)
E/flutter (15195): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #24 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4742:32)
E/flutter (15195): #25 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #29 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #30 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3752:11)
E/flutter (15195): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #34 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #35 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #36 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #37 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #40 ComponentElement.performRebuild (packag
E/flutter (15195): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (15195): type 'Future<Object>' is not a subtype of type 'FutureOr<PageAnswer>' where
E/flutter (15195): Future is from dart:async
E/flutter (15195): Object is from dart:core
E/flutter (15195): FutureOr is from dart:async
E/flutter (15195): PageAnswer is from file:///D:/Development/appli/lib/libraries/function_types.dart
E/flutter (15195):
E/flutter (15195): #0 MIDApi.getItems (file:///D:/Development/appli/lib/libraries/api.dart:34:8)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #1 _ItemsPageState.request (file:///D:/Development/appli/lib/pages/items.dart:30:39)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #2 PagedGridViewState.onRefresh (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:160:38)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #3 PagedGridViewState.Clear (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:85:11)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #4 _ItemsPageState._onSortOrderChanged.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:67:29)
E/flutter (15195): #5 State.setState (package:flutter/src/widgets/framework.dart:1108:30)
E/flutter (15195): #6 _ItemsPageState._onSortOrderChanged (file:///D:/Development/appli/lib/pages/items.dart:65:5)
E/flutter (15195): #7 _ItemsPageState.build.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:114:9)
E/flutter (15195): #8 _PopupMenuButtonState.showButtonMenu.<anonymous closure> (package:flutter/src/material/popup_menu.dart)
E/flutter (15195): #9 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (15195): #10 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (15195): #11 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (15195): #12 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (15195): #13 Future._completeWithValue (dart:async/future_impl.dart:477:5)
E/flutter (15195): #14 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507:7)
E/flutter (15195): #15 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (15195): #16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
I/flutter (15195): Another exception was thrown: type '() => Future<dynamic>' is not a subtype of type '() => Future<Null>'
E/flutter (15195): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (15195): type '() => Type' is not a subtype of type '(Object) => FutureOr<Object>'
E/flutter (15195): #0 _FutureListener.handleError (dart:async/future_impl.dart:145:11)
E/flutter (15195): #1 Future._propagateToListeners.handleError (dart:async/future_impl.dart:645:47)
E/flutter (15195): #2 Future._propagateToListeners (dart:async/future_impl.dart:666:24)
E/flutter (15195): #3 Future._completeError (dart:async/future_impl.dart:485:5)
E/flutter (15195): #4 _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
E/flutter (15195): #5 _Completer.completeError (dart:async/future_impl.dart:27:5)
E/flutter (15195): #6 MIDApi.getItems.<anonymous closure> (file:///D:/Development/appli/lib/libraries/api.dart)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #7 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (15195): #8 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (15195): #9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (15195): #10 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (15195): #11 Future._complete (dart:async/future_impl.dart:467:7)
E/flutter (15195): #12 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (15195): #13 ajaxGet (file:///D:/Development/appli/lib/libraries/ajax.dart)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #14 MIDApi.getItems (file:///D:/Development/appli/lib/libraries/api.dart:21:12)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #15 _ItemsPageState.request (file:///D:/Development/appli/lib/pages/items.dart:30:39)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #16 PagedGridViewState.onRefresh (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:160:38)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #17 PagedGridViewState.Clear (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:85:11)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #18 _ItemsPageState._onSortOrderChanged.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:67:29)
E/flutter (15195): #19 State.setState (package:flutter/src/widgets/framework.dart:1108:30)
E/flutter (15195): #20 _ItemsPageState._onSortOrderChanged (file:///D:/Development/appli/lib/pages/items.dart:65:5)
E/flutter (15195): #21 _ItemsPageState.build.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:114:9)
E/flutter (15195): #22 _PopupMenuButtonState.showButtonMenu.<anonymous closure> (package:flutter/src/material/popup_menu.dart)
E/flutter (15195): #23 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (15195): #24 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (15195): #25 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (15195): #26 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (15195): #27 Future._completeWithValue (dart:async/future_impl.dart:477:5)
E/flutter (15195): #28 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507:7)
E/flutter (15195): #29 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (15195): #30 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)