• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

I got this simple build function which should show a dialog when the snapshot has an error, but I'm unable to do so without getting the following error:

flutter: The following assertion was thrown building FutureBuilder(dirty, dependencies: flutter: [_LocalizationsScope-[GlobalKey#f4f3f], _InheritedTheme], state: flutter: _FutureBuilderState#175f8): flutter: setState() or markNeedsBuild() called during build. flutter: This Overlay widget cannot be marked as needing to build because the framework is already in the flutter: process of building widgets. A widget can be marked as needing to be built during the build phase flutter: only if one of its ancestors is currently building. This exception is allowed because the framework flutter: builds parent widgets before children, which means a dirty descendant will always be built. flutter: Otherwise, the framework might not visit this widget during this build phase. flutter: The widget on which setState() or markNeedsBuild() was called was: flutter:


showUnknownErrorAlertDialog(BuildContext context, [void Function() onClose]) {    showDialog(     context: context,     builder: (BuildContext builderContext) {        return AlertDialog(         title: Text(AppLocalizations.of(builderContext).lang['unknownError']),         actions: [            FlatButton(             child: Text(AppLocalizations.of(builderContext).lang['close']),             onPressed: () {               Navigator.of(builderContext).pop();                if (onClose != null) {                 onClose();               }             },           ),         ],       );     }   ); }  goBack() {   locator().navigateTo('gameOverview', AppGameArgs(gameName)); }    @override   Widget build(BuildContext context) {     return FutureBuilder(       future: getGameSession(),       builder: (context, AsyncSnapshot snapshot) {          if (snapshot.hasError) {            return showUnknownErrorAlertDialog(context, () {             goBack();           });         }         / ... omitted code .../ 

How am I supposed to handle errors in the build function if I'm not allowed to show a dialog or navigate away instantly when there's an error?

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]