Const themes lead to multiple `dart(unused_element)`
jtdLab opened this issue · 2 comments
jtdLab commented
When running the generator on a const theme like this:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' show Theme, ThemeExtension;
import 'package:flutter/widgets.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
part 'color_theme.tailor.dart';
@Tailor(requireStaticConst: true)
class _$ColorTheme {
static const primary = [
Color(0xFFFFFFFF),
Color(0xFF222222),
];
static const secondary = [
Color(0xFF3277B4),
Color(0xFF284D72),
];
}
leads to dart(unused_element)
.
Rongix commented
Hello, if you take a look at the example here, you can see that we ignore these lints for the files that use this generator's feature. Require static const makes sure everything in the class is const so it can just copy it over to the generated file. It means that the original file is just a "template" for the generator; it is not used for anything but the generation part. https://github.com/Iteo/theme_tailor/blob/main/packages/theme_tailor/example/lib/constant_theme.dart
// ignore_for_file: unused_element, unused_field
So it's working as expected
jtdLab commented
great ty