theme_provider 0.0.1+8 copy "theme_provider: ^0.0.1+8" to clipboard
theme_provider: ^0.0.1+8 copied to clipboard

outdated

Easy to use, customizable and pluggable Theme Provider. This Widget can be used to easily provide a theme controller across the widget tree.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ThemeProvider(
      themes: <AppTheme>[
        AppTheme.light(),
        AppTheme.dark(),
        customTheme(),
      ],
      builder: (context, theme) => MaterialApp(
            theme: theme,
            home: HomePage(),
          ),
    );
  }
}

AppTheme customTheme() => AppTheme(
      data: ThemeData(
        accentColor: Colors.yellow,
        primaryColor: Colors.red,
      ),
      id: "custom_theme",
      description: "Light Theme w/ Red",
    );

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Example App"),
      ),
      body: Center(
        child: IntrinsicWidth(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(4.0),
                child: Text(
                    "Current Theme: ${ThemeProvider.controllerOf(context).currentThemeId}"),
              ),
              Padding(
                padding: const EdgeInsets.all(4.0),
                child: OutlineButton(
                  child: Text("Next Theme"),
                  onPressed: ThemeProvider.controllerOf(context).nextTheme,
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(4.0),
                child: OutlineButton(
                  child: Text("Theme Dialog"),
                  onPressed: () => showDialog(
                      context: context, builder: (_) => ThemeDialog()),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
300
likes
0
pub points
95%
popularity

Publisher

unverified uploader

Easy to use, customizable and pluggable Theme Provider. This Widget can be used to easily provide a theme controller across the widget tree.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on theme_provider