-
Notifications
You must be signed in to change notification settings - Fork 28.7k
FadeInImage throws null pointer exception (Flutter 3.3) #111011
New issue
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Issue is reproducible on the latest videoSimulator.Screen.Recording.-.iPhone.13.Pro.-.2022-09-06.at.08.17.54.mp4code sampleimport 'package:flutter/material.dart';
import 'dart:typed_data';
final Uint8List kTransparentImage = Uint8List.fromList(<int>[
0x89,
0x50,
0x4E,
0x47,
0x0D,
0x0A,
0x1A,
0x0A,
0x00,
0x00,
0x00,
0x0D,
0x49,
0x48,
0x44,
0x52,
0x00,
0x00,
0x00,
0x01,
0x00,
0x00,
0x00,
0x01,
0x08,
0x06,
0x00,
0x00,
0x00,
0x1F,
0x15,
0xC4,
0x89,
0x00,
0x00,
0x00,
0x0A,
0x49,
0x44,
0x41,
0x54,
0x78,
0x9C,
0x63,
0x00,
0x01,
0x00,
0x00,
0x05,
0x00,
0x01,
0x0D,
0x0A,
0x2D,
0xB4,
0x00,
0x00,
0x00,
0x00,
0x49,
0x45,
0x4E,
0x44,
0xAE,
]);
void main() async {
runApp(const MyApp());
}
const _kImages = [
'https://pub.dev/static/hash-t3bgi1vk/img/landing-01.webp',
'https://pub.dev/static/hash-t3bgi1vk/img/landing-02.webp',
'https://pub.dev/static/hash-t3bgi1vk/img/landing-03.webp',
];
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: FutureBuilder<void>(
// Preload the first image
future: precacheImage(NetworkImage(_kImages[0]), context),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Material(
child: Center(child: CircularProgressIndicator()));
}
return const MyHomePage(title: 'Flutter Demo Home Page');
}),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: _kImages[_counter % _kImages.length],
),
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
// Click the button to switch images
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
flutter doctor -v
logs
|
cc: @werainkhatri |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
@chunhtai can you open a cherry-pick request using the standard template? Removing the cp: review label from this issue. |
Uh oh!
There was an error while loading. Please reload this page.
FadeInImage throws null pointer exception when switching from a cached image to an uncached image
It is possible that this PR is causing the problem.
Steps to Reproduce
flutter run
on the code sampleExpected results:
Switch images normally.
Actual results:

Throwing exceptions:
Null check operator used on a null value
Code sample
demo_fade_in_image_null_3.zip
Logs
Full log
The text was updated successfully, but these errors were encountered: