widget_theme 0.1.0-dev.2 copy "widget_theme: ^0.1.0-dev.2" to clipboard
widget_theme: ^0.1.0-dev.2 copied to clipboard

Code generation utilities for creating widget-specific theme models from Flutter widget properties, enabling scalable and consistent theming.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:widget_theme_annotation/widget_theme_annotation.dart';

part 'main.freezed.dart';
part 'main.theme.dart';

@widgetTheme
class MyWidget extends StatelessWidget {
  const MyWidget({
    this.padding,
    this.color,
    super.key,
  });

  final Color? color;
  final EdgeInsets? padding;

  @override
  Widget build(BuildContext context) {
    final theme = MyWidgetTheme.of(context);

    return Padding(
      padding: padding ?? theme.padding ?? const EdgeInsets.all(8),
      child: Text(
        'Hello world!',
        style: TextStyle(color: color ?? theme.color),
      ),
    );
  }
}

void main() => runApp(const MainApp());

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyWidgetTheme(
        data: .new(color: Colors.red, padding: .zero),
        child: Scaffold(
          body: Center(child: MyWidget()),
        ),
      ),
    );
  }
}
0
likes
0
points
16
downloads

Publisher

verified publisheralbinpk.dev

Weekly Downloads

Code generation utilities for creating widget-specific theme models from Flutter widget properties, enabling scalable and consistent theming.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, build, code_builder, dart_style, source_gen, widget_theme_annotation

More

Packages that depend on widget_theme