-
Notifications
You must be signed in to change notification settings - Fork 329
Description
Steps to Reproduce
Run this:
import 'package:flutter/material.dart';
void main() async {
runApp(
const Scaffold(
body: Preview.enforce(title: 'test'),
),
);
}
class Preview extends StatelessWidget {
const Preview({String? title}) : title = title ?? 'default';
const Preview.enforce({required String this.title});
final String? title;
@override
Widget build(BuildContext context) {
return Text(title!);
}
}
... then try to change anything in the file : the hot reload won't work.
The problem here is the enforced non-nullable this.title in the alternative constructor, which is correct Dart syntax and should not break anything regarding hot reload / hot restart ; Changing to const Preview.enforce({required this.title}); fixes the issue.
Strangely, please note that making an error-free save in any other .dart file that does not has this scenario within it makes hot restart / hot reload happen normally.
Version info
Flutter Plugin: 72.0.2
Dart Plugin: 221.6096
/Users/guillaumevara/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 3.7.1, on macOS 13.1 22C65 darwin-arm64, locale fr-FR)
• Flutter version 3.7.1 on channel stable at /Users/guillaumevara/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7048ed95a5 (il y a 2 jours), 2023-02-01 09:07:31 -0800
• Engine revision 800594f1f4
• Dart version 2.19.1
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/guillaumevara/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• ANDROID_SDK_ROOT = /Users/guillaumevara/Library/Android/sdk
• Java binary at: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Zulu11.58+23-CA (build 11.0.16.1+1-LTS)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (version 2022.1)
• 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
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] VS Code (version 1.75.0)
• 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 (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Process finished with exit code 0