-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listdependency: dartDart team may need to help usDart team may need to help usfound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
Expected results:
I should be able to use NavigationBar as compile time constant as it has const constructor like this
const navigationBar = NavigationBar(
destinations: const [
NavigationDestination(
icon: Icon(Icons.contacts),
label: 'Contacts',
),
NavigationDestination(
icon: Icon(Icons.people),
label: 'Players',
),
],
);
Actual results:
The code above does not compile throwing
lib/domains/user/contacts.dart:55:29: Error: Constant evaluation error:
const navigationBar = NavigationBar(
^
/opt/flutter/packages/flutter/lib/src/material/navigation_bar.dart:76:53: Context: The property 'length' can't be accessed on '<Widget>[NavigationDestination {icon: Icon {icon: IconData {codePoint: 57743.0, fontFamily: "MaterialIcons", fontPackage: null, matchTextDirection: false}, size: null, color: null, semanticLabel: null, textDirection: null}, selectedIcon: null, label: "Contacts", tooltip: null}, NavigationDestination {icon: Icon {icon: IconData {codePoint: 58502.0, fontFamily: "MaterialIcons", fontPackage: null, matchTextDirection: false}, size: null, color: null, semanticLabel: null, textDirection: null}, selectedIcon: null, label: "Players", tooltip: null}]' in a constant expression.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('/opt/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'NavigationDestination' is from 'package:flutter/src/material/navigation_bar.dart' ('/opt/flutter/packages/flutter/lib/src/material/navigation_bar.dart').
- 'Icon' is from 'package:flutter/src/widgets/icon.dart' ('/opt/flutter/packages/flutter/lib/src/widgets/icon.dart').
- 'IconData' is from 'package:flutter/src/widgets/icon_data.dart' ('/opt/flutter/packages/flutter/lib/src/widgets/icon_data.dart').
}) : assert(destinations != null && destinations.length >= 2),
^
lib/domains/user/contacts.dart:55:13: Context: While analyzing:
const navigationBar = NavigationBar(
^
Failed to compile application.
Flutter --version output:
Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (6 days ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listdependency: dartDart team may need to help usDart team may need to help usfound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version