We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
On the home widget, the temperature and date display correctly, but the image does not. I followed the example explanation and here is a code snippet.
home_widget/example/lib/main.dart
Lines 118 to 125 in 365f8f9
try { print(state.weather.theme.image); await Future.wait([ HomeWidget.saveWidgetData('date', state.weather.date), HomeWidget.saveWidgetData( 'temperature', state.weather.temperature.toString()), HomeWidget.updateWidget(androidName: 'WeatherWidget'), HomeWidget.renderFlutterWidget( Image.asset(state.weather.theme.image), key: 'image', ), ]); } on PlatformException catch (exception) { log("Error Sending Data", error: exception); }
I/flutter (31368): assets/images/weather/Day Sun.webp // <- the image exist E/BitmapFactory( 2649): Unable to decode stream: java.io.FileNotFoundException: Image: open failed: ENOENT (No such file or directory) I/AppWidgetManager(31368): updateAppWidget() appWidgetIds = [29] E/flutter (31368): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Failed to render the widget: Exception: Invalid image dimensions. E/flutter (31368): #0 HomeWidget.renderFlutterWidget (package:home_widget/src/home_widget.dart:264:7) E/flutter (31368): <asynchronous suspension> E/flutter (31368): #1 Future.wait.<anonymous closure> (dart:async/future.dart:518:21) E/flutter (31368): <asynchronous suspension> E/flutter (31368): #2 HomeScreen.build.<anonymous closure> (package:clima/features/home/screens/home_screen.dart:23:13) E/flutter (31368): <asynchronous suspension> E/flutter (31368):
home_widget/example/android/app/src/main/kotlin/es/antonborri/home_widget_example/HomeWidgetExampleProvider.kt
Lines 38 to 44 in 365f8f9
appWidgetIds.forEach { widgetId -> val views = RemoteViews(context.packageName,R.layout.weather_widget).apply { val widgetData = HomeWidgetPlugin.getData(context) val temp = widgetData.getString("temperature","Temperature") val date = widgetData.getString("date","Date") val image = widgetData.getString("image", null) if (image != null) { setImageViewBitmap(R.id.image, BitmapFactory.decodeFile(image)) setViewVisibility(R.id.image, View.VISIBLE) } else { setViewVisibility(R.id.image, View.GONE) } setTextViewText(R.id.temperature,temp) setTextViewText(R.id.date,date) } appWidgetManager.updateAppWidget(widgetId,views) }
<?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:description="@string/app_widget_description" android:initialKeyguardLayout="@layout/weather_widget" android:initialLayout="@layout/weather_widget" android:minWidth="40dp" android:minHeight="40dp" android:previewImage="@drawable/example_appwidget_preview" android:previewLayout="@layout/weather_widget" android:resizeMode="horizontal|vertical" android:targetCellWidth="3" android:targetCellHeight="2" android:updatePeriodMillis="86400000" android:widgetCategory="home_screen" />
I understand that the image may be large, but there are no restrictions in the documentation.
HomeWidget.renderFlutterWidget( Image.asset( state.weather.theme.image, width: 100, height: 100, ), key: 'image', ),
The code is no longer throwing an Exception, but the image is still not appearing.
Exception
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Widget.Android.AppWidget.Container" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" android:background="@color/white" android:padding="16dp" > <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" android:layout_margin="8dp" android:contentDescription="@string/weather_image" /> <TextView android:id="@+id/temperature" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="8dp" android:contentDescription="@string/temperature" android:textSize="24sp" android:textStyle="bold|italic" /> <TextView android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="8dp" android:contentDescription="@string/date" android:textSize="16sp" android:textStyle="bold|italic" /> </LinearLayout>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
On the home widget, the temperature and date display correctly, but the image does not. I followed the example explanation and here is a code snippet.
What I follow
home_widget/example/lib/main.dart
Lines 118 to 125 in 365f8f9
Dart Code
Log
What I follow
home_widget/example/android/app/src/main/kotlin/es/antonborri/home_widget_example/HomeWidgetExampleProvider.kt
Lines 38 to 44 in 365f8f9
Native Code
Widget Info
I understand that the image may be large, but there are no restrictions in the documentation.
The Problem is the image is not appearing even if I resize it
The code is no longer throwing an
Exception
, but the image is still not appearing.Native Ui
The text was updated successfully, but these errors were encountered: