custom_theme 0.1.0 copy "custom_theme: ^0.1.0" to clipboard
custom_theme: ^0.1.0 copied to clipboard

discontinued
outdated

Custom theme with user data support. Plugin wrap standard Flutter ThemeData to CustomData and allow to add some user defined data. Wrapped data is passed to MaterialApp theme and darkTheme params and [...]

example/lib/main.dart

import 'package:custom_theme/custom_theme.dart';
import 'package:example/my_themes.dart';
import 'package:flutter/material.dart';

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

final themeNotifier = ValueNotifier<CustomTheme>(LightTheme1());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder<CustomTheme>(
      valueListenable: themeNotifier,
      builder: (context, theme, child) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: theme,
          darkTheme: DarkTheme(),
          home: child,
        );
      },
      child: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  @override
  Widget build(BuildContext context) {
    debugPrint("getMyData(context).size=${getMyData(context).size}");

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            Text(
              getMyData(context).text,
            ),
            AnimatedContainer(
              duration: Duration(milliseconds: 300),
              width: getMyData(context).size,
              height: getMyData(context).size,
              decoration: BoxDecoration(
                color: getMyData(context).squareColor,
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          ++_counter;

          if (_counter == 1) {
            themeNotifier.value = LightTheme2();
          } else if (_counter == 2) {
            themeNotifier.value = DarkTheme();
          } else {
            _counter = 0;
            themeNotifier.value = LightTheme1();
          }
        },
        child: Icon(Icons.alternate_email),
      ),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Custom theme with user data support. Plugin wrap standard Flutter ThemeData to CustomData and allow to add some user defined data. Wrapped data is passed to MaterialApp theme and darkTheme params and then can be easily retrieved later and used anywhere in widgets tree.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on custom_theme