Closed
Description
Small but easy issue: docs for Image's loadingBuilder don't show the ImageChunkEvent param as optional. Docs just need to have the ?
to show the implementation
Steps to Reproduce
- Execute
flutter run
on the code sample
Expected results: Flutter logo loads
Actual results: Dart fails to compile
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: "Example",
home: Image.network(
// Flutter logo
"https://storage.googleapis.com/cms-storage-bucket/c823e53b3a1a7b0d36a9.png",
// Non-working code, copied directly from documentation
// Works if ImageChunkEvent is marked as optional with ?
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) {
return Center(child: child);
},
),
),
);
}
Logs
lib/example.dart:9:25: Error: The argument type 'Center Function(BuildContext, Widget, ImageChunkEvent)' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget, ImageChunkEvent?)?' because 'ImageChunkEvent?' is nullable and 'ImageChunkEvent' isn't.
- 'Center' is from 'package:flutter/src/widgets/basic.dart' ('/usr/local/Caskroom/flutter/3.0.5/flutter/packages/flutter/lib/src/widgets/basic.dart').
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/usr/local/Caskroom/flutter/3.0.5/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('/usr/local/Caskroom/flutter/3.0.5/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'ImageChunkEvent' is from 'package:flutter/src/painting/image_stream.dart' ('/usr/local/Caskroom/flutter/3.0.5/flutter/packages/flutter/lib/src/painting/image_stream.dart').
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) {
^
error • The argument type 'Center Function(BuildContext, Widget, ImageChunkEvent)' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget, ImageChunkEvent?)?' • lib/example.dart:13:25 • argument_type_not_assignable
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5 21G72 darwin-x64, locale en-US)
• Flutter version 3.0.5 at /usr/local/Caskroom/flutter/3.0.5/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (3 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/parker/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.65.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• ONEPLUS A5010 (mobile) • db59e1c • android-arm64 • Android 10 (API 29)
• macOS (desktop) • macos • darwin-x64 • macOS 12.5 21G72 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!