Closed Ritsz123 closed 1 year ago
All you need to do is to declare the type of the variable:
class Product {}
typedef SomeStructure
= Map<String, Map<String, Map<String, Map<String, List<Product>>>>>;
void main() {
SomeStructure myMap = {};
// int i = myMap; // Include this to see the static type of `myMap` in the error message.
print(myMap.runtimeType); // Show the dynamic type.
}
The declared type of the variable serves as input to type inference, and this ensures that the plain {}
is implicitly taken to mean String, Map<String, Map<String, Map<String, List<Product>>>>{}
.
I'll close the issue because it is all working as intended.
PS: When creating an issue, please make sure you've removed all placeholder text elements before you press 'Submit', e.g.:
Thank you for taking the time to file an issue!
I've defined a type using
typedef SomeStructure = Map<String, Map<String, Map<String, Map<String, List<Product>>>>>;
now when I try to use it in this way
final someStrucutreObject = SomeStructure();
the plugin gives me the suggestion to convert it to map literal now the problem is if I convert it to map literal {} the type will becomeMap<dynamic,dynamic>
which is not what I needed.Some other pieces of the Dart ecosystem are maintained elsewhere. Please file issues in their repository:
flutter doctor -v output
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19045.2311], locale en-IN) • Flutter version 3.0.5 at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (5 months ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK v ersion 33.0.0) • Android SDK at C:\Users\Ritesh\AppData\Local\Android\Sdk • Platform android-33, build-tools 33.0.0 • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.
[√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.2) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.0.31919.166 • Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.3) • Android Studio at C:\Program Files\Android\Android Studio1 • 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.13+0-b1751.21-8125866)
[√] IntelliJ IDEA Ultimate Edition (version 2022.1) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.3 • 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
[√] VS Code, 64-bit edition (version 1.73.1) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension version 3.18.1
[√] Connected device (4 available) • RMX3392 (mobile) • CY85DIH6CEL79XU4 • android-arm64 • Android 12 (API 31) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.2311] • Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.121 • Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.52
[√] HTTP Host Availability • All required HTTP hosts are available
• No issues found!