-
Notifications
You must be signed in to change notification settings - Fork 1.7k
error: Not a constant expression - only at runtime #33883
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
[✓] Flutter (Channel master, v0.5.8-pre.58, on Mac OS X 10.13.6 17G65, locale en-AT) [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) [✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1) [✓] Android Studio (version 3.1) [✓] IntelliJ IDEA Ultimate Edition (version 2018.1.5) [✓] Connected devices (1 available) • No issues found! |
Can't reproduce anymore. |
Still the same. Made a mistake when testing. |
I can't reproduce this from just the snippets of code above. Unfortunately, the same error message "Not a constant expression." is used in both the front end compiler and the Dart VM, so I can't even localize the problem from the (bad) stack trace. Is it possible we could get a standalone reproduction? |
Thanks for having a look. |
The simplest reproduction I was able to come up with is import 'package:flutter/widgets.dart';
void main() {
print(SplashScreen.tenant());
}
abstract class SplashScreen extends StatelessWidget {
const SplashScreen.base();
factory SplashScreen.tenant() => const SplashScreenFoo();
}
class SplashScreenFoo extends SplashScreen {
const SplashScreenFoo() : super.base();
@override
Widget build(BuildContext context) {
// TODO: implement build
}
} I wasn't able to reproduce without extending from |
Currently at $ flutter doctor -v [✓] Android toolchain - develop for Android devices (Android SDK 28.0.1) [✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1) [✓] Android Studio (version 3.1) [✓] IntelliJ IDEA Ultimate Edition (version 2018.2) [✓] Connected devices (1 available) • No issues found! |
I use a class with a const constructor with
new
and it complains that it is not a constant expression even though none should be required.I'm also pretty sure I didn't make changes related to this code since a few months and it worked so far.
DartAnalyzer doesn't show any hints or warnings
here
_createSplashScreen()
is calledthe implementation
the class with the const constructor
The error message is not very helpful. See also #33438
The text was updated successfully, but these errors were encountered: