google / google/reflectable.dart
Cannot reflect ```flutter/material.dart``` URIs for ```Container``` type
- Dominant language
- Dart
- Stars
- 386
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Hi all -
I'm creating an ```analyzer``` based utility package, to more-easily allow developers to create lint rules, quick assists, etc, and one of the individual proof-of-concepts I'm designing is a more intuitive API for interacting with AST utilities like type-checkers. For more context, you can check out [sidecar](https://github.com/pattobrien/sidecar) (the aforementioned analyzer utility) and [reflectable_flutter_analyzer](https://github.com/pattobrien/reflectable_flutter_analyzer) (attempted PoC of a Flutter-based analyzer that uses reflectable package).
As the title explains, I'm unable to reflect ```flutter/material.dart``` type URIs using ```package:reflectable```, which are needed to perform runtime-checking of a URI match between an analyzer Element's source URI and the expected URI of the Type (e.g. Container). I have this working for ```dart.ui.Color``` but it does not work for ```Container``` from ```package:flutter```:
```dart
import 'package:flutter/material.dart';
import 'package:reflectable_analyzer/reflectable_analyzer.dart';
@GlobalQuantifyCapability(r'\.Color$', analyzerReflector)
@GlobalQuantifyCapability(r'\.Container$', analyzerReflector)
import 'package:reflectable/reflectable.dart' hide SourceLocation;
import 'reflector.reflectable.dart';
void main() {
initializeReflectable();
}
```
The above code incorrectly generates the following:
```dart
...
[
r.LibraryMirrorImpl(
r'dart.ui', // Correct library mirror for ```dart.ui.Color```
Uri.parse(r'reflectable://0/dart.ui'),
...
),
r.LibraryMirrorImpl(
r'', // Blank library mirror for ```flutter.material.Container```
Uri.parse(r'reflectable://1/'),
...
),
],
...
```
```dart
[
r.NonGenericClassMirrorImpl(
r'Color',
r'dart.ui.Color', // Correct qualified name
...
),
r.NonGenericClassMirrorImpl(
r'Container',
r'.Container', // Expected ```flutter.material.Container``` or something similar
...
),
```
Contributor guide
Assessment
This issue has not been assessed yet.