of static method

CLTheme of(
  1. BuildContext context
)

Implementation

static CLTheme of(BuildContext context) {
  final isDark = Theme.of(context).brightness == Brightness.dark;

  // 1. Cerca il provider generico (nuovo, consigliato)
  try {
    final tp = Provider.of<CLThemeProvider>(context);
    return isDark ? tp.darkTheme : tp.lightTheme;
  } catch (_) {}

  // 2. Fallback: cerca il vecchio ModuleThemeProvider (retrocompatibilità)
  try {
    // ignore: deprecated_member_use_from_same_package
    final mp = Provider.of<ModuleThemeProvider>(context);
    return isDark ? mp.darkTheme : mp.lightTheme;
  } catch (_) {}

  // 3. Default built-in
  return isDark ? dark : light;
}