Unexpected error in flutter without any errors - flutter

Im getting this unexpected error without changed in the code and no error being pointed
Exception caught by scheduler library ═════════════════════════════════
'package:flutter/src/widgets/binding.dart': Failed assertion: line 849 pos 12: '!debugBuildingDirtyElements': is not true.
Any idea what is it?

Related

Using Edge or Chrome to debug Flutter Applications

I'm trying to debug my app using edge.
And the first time it run...
It throws me exception saying...
══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following ImageCodecException was thrown resolving an image codec:
Failed to load network image.
Image URL: https://i.ytimg.com/vi/eCx7dzYqb98/maxresdefault.jpg
Trying to load an image from another domain? Find answers at:
https://flutter.dev/docs/development/platform-integration/web-images
When the exception was thrown, this was the stack
Image provider: CachedNetworkImageProvider("https://i.ytimg.com/vi/eCx7dzYqb98/maxresdefault.jpg",
scale: 1)
Image key: CachedNetworkImageProvider("https://i.ytimg.com/vi/eCx7dzYqb98/maxresdefault.jpg",
scale: 1):
CachedNetworkImageProvider("https://i.ytimg.com/vi/eCx7dzYqb98/maxresdefault.jpg", scale: 1)
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: ImageCodecException: Failed to load network image.
Another exception was thrown: ImageCodecException: Failed to load network image.
But after I reloaded / restarted app...
Everything is working fine...
What is the reason for this?
When I debug on my mobile phone (I'm using it as emulator) everything is working fine...

The following NetworkImageLoadException was thrown resolving an image codec: HTTP request failed, statusCode: 404

When I call this function the error occurs.
Image.network(
i.toString(),
errorBuilder:((context, error, stackTrace) =>
const Icon(Icons.account_circle)))
If failed to get image, shows icon instead. But the error below is displayed.
════════ Exception caught by image resource service ════════════════════════════
The following NetworkImageLoadException was thrown resolving an image codec:
HTTP request failed, statusCode: 404, https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Google-flutter-logo.svg/2560px-Google-flutter-logo.svg.png
When the exception was thrown, this was the stack
#0 NetworkImage._loadAsync
package:flutter/…/painting/_network_image_io.dart:97
<asynchronous suspension>
Image provider: NetworkImage("https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Google-flutter-logo.svg/2560px-Google-flutter-logo.svg.png", scale: 1.0)
Image key: NetworkImage("https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Google-flutter-logo.svg/2560px-Google-flutter-logo.svg.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════
Why this error occurs even I set errorBuilder? I tried other URLs but sometimes this error displayed.
I hope this exception is related to http call made by the widget not related to the error widget builder.
As we can the error states 404 http status code.
If handling the exception is required you can also try cached image package.
below is the link for the package.
Package link: https://pub.dev/packages/cached_network_image

Android studio flutter logs stacktrace doesn't show correct line number

Android studio for flutter doesn't show correct line number in console.
For e.g.
The following ArgumentError was thrown resolving an image codec:
Invalid argument(s): No host specified in URI file:///
When the exception was thrown, this was the stack:
#0 _HttpClient._openUrl (dart:_http/http_impl.dart:2667:9)
#1 _HttpClient.getUrl (dart:_http/http_impl.dart:2575:48)
#2 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:87:59)
#3 NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:50:14)
And now have NetworkImage widget all over the code. How to figure out which line is causing this ?

The following ProviderNotFoundException was thrown building Consumer<ThemeProvider>(dirty)

Error: Could not find the correct Provider above this Consumer Widget
EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK
The following TestFailure object was thrown running a test:
Expected: exactly one matching node in the widget tree
Actual: _TextFinder:<zero widgets with text "0" (ignoring offstage widgets)>
Which: means none were found but one was expected
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///C:/flutter/MyProject/dumpit/test/widget_test.dart:19:5)
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///C:/flutter/MyProject/dumpit/test/widget_test.dart line 19
The test description was:
Counter increments smoke test
There was default test case file present in test folder which was against my app model and hence threw an error. I got rid of it to solve my test run

reuse a gtk_file_chooser_dialog multiple times

I'd like to re-use a gtk_file_chooser_dialog multiple times. But after the user closes the dialog the first time, the pointer to the GtkFileChooserDialog struct seems broken.
Opening the diaglog the first time succeeds.
Opening the same dialog a second time results in
(crystal_facet_uml:3797): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkWidget'
(crystal_facet_uml:3797): Gtk-CRITICAL **: gtk_widget_show_all: assertion 'GTK_IS_WIDGET (widget)' failed
My first idea was to increase the reference counter on the dialog to prevent it from being cleaed up:
(*this_).use_db_file_chooser = gtk_file_chooser_dialog_new ( "Select DB to use",
GTK_WINDOW( (*this_).window ),
GTK_FILE_CHOOSER_ACTION_SAVE,
"Cancel",
GTK_RESPONSE_CANCEL,
"Create/Use DB-File",
GTK_RESPONSE_ACCEPT,
NULL
);
g_object_ref( (*this_).use_db_file_chooser );
... but this only shifts the problem: the dialog-window seems to stay but the contained widgets are gone:
(crystal_facet_uml:3797): Gtk-CRITICAL **: gtk_container_foreach: assertion 'GTK_IS_CONTAINER (container)' failed
(crystal_facet_uml:3797): Gtk-CRITICAL **: gtk_container_foreach: assertion 'GTK_IS_CONTAINER (container)' failed
(crystal_facet_uml:3797): Gtk-CRITICAL **: gtk_container_foreach: assertion 'GTK_IS_CONTAINER (container)' failed
(crystal_facet_uml:3797): Gtk-CRITICAL **: gtk_container_foreach: assertion 'GTK_IS_CONTAINER (container)' failed
(crystal_facet_uml:3797): Gtk-CRITICAL **: _gtk_file_chooser_embed_initial_focus: assertion 'GTK_IS_FILE_CHOOSER_EMBED (chooser_embed)' failed
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
(crystal_facet_uml:3797): Gtk-CRITICAL **: gtk_container_foreach: assertion 'GTK_IS_CONTAINER (container)' failed
Do you have an idea how to do this right?
(Rationale for re-using the file chooser dialogs are: 1) I want to allocate it in the beginning and afterwards not care about NULL-pointers anymore, 2) I want to keep the contents of the dialog (current folder, current filename), 3) I want to start this non-modal dialog only once, never 2 dialogs at the same time, 4) I want to keep the g_signal bindings throughout the lifetime of my program).
(full source code: https://sourceforge.net/p/crystal-facet-uml/code/ci/46ee183ea06baae3af70d81c74efe767fccc5028/tree/gui/source/gui_main_window.c )
I found a nice solution (with the help of the answer to C GTK can't open Dialog again after closing via ESC and the documentation on https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-delete-event ):
simply connect the delete-event of the dialog to the gtk-predefined callback function gtk_widget_hide_on_delete():
g_signal_connect( G_OBJECT((*this_).use_db_file_chooser), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL );
And your dialog-object is not destroyed when the user closes it.