Giter Site home page Giter Site logo

lvfarias / easy_theme Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 79 KB

A package to generate MaterialColors and a ThemeData for your Flutter App in an EASY and FAST WAY.

Home Page: https://pub.dev/packages/easy_theme

License: Other

Dart 98.53% Kotlin 0.32% Swift 1.05% Objective-C 0.10%
dart flutter theme theme-customizer material material-theme material-colors generator

easy_theme's Introduction

Easy Theme

Language Framework Version License Tests Tests Last Commit

Sumary

Description

A package to generate MaterialColors and a ThemeData for your Flutter App in an EASY and FAST WAY.

Installation

Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  easy_theme: ^1.0.2

Install it

You can install packages from the command line:

with Flutter:

flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:easy_theme/easy_theme.dart';

Use it

Now in your Dart code, you can use:

final EasyTheme myCustomTheme = EasyTheme(primary: Colors.blue);

What is CustomTheme?

Is the main class of the package, it will be responsible for generating a theme for your app and a color variable, which facilitates work and understanding.

When instantiation the class, it is mandatory to pass a primary color as a parameter, but it is also possible to pass the colors: secondary, success, info, warning, error. It is also possible to pass a brightness to build dark or light themes.

This class there are two public functions, they are:

  • getColors that returns an object of type EasyColors
  • getTheme that returns an object of type ThemeData

EasyColors

Is a class that transforms the colors passed in CustomTheme to MaterialColors, and puts it in an easy to understand structure to be used in the application.

It contains the following MaterialColors: primary; secondary; success; info; warning; error; white; black;

White is #FFFFFF and Black is #000000.

Secondary, if not provided at CustomTheme instantiation, a complementary color to the primary calculated by the EasyColors class.

Customize

Try to pass more colors to CustomTheme for a more personalized theme.

final EasyTheme myEasyTheme = EasyTheme(
    primary: Color(0XFF0F4C81),
    secondary: Color(0XFFCFA904),
    success: : Color(0XFF268209),
    info: : Color(0XFF09827A),
    warning: : Color(0XFFB49404),
    error: : Color(0XFF82211D),
    brightness: Brightness.light,
);

You can also create more than one theme for your application, as in the example below a dark and light theme is created

final EasyTheme myEasyThemeLight = EasyTheme(
    primary: Color(0XFF0F4C81),
    secondary: Color(0XFFCFA904),
    success: : Color(0XFF268209),
    info: : Color(0XFF09827A),
    warning: : Color(0XFFB49404),
    error: : Color(0XFF82211D),
    brightness: Brightness.light,
);

final EasyTheme myEasyThemeDark = EasyTheme(
    primary: Color(0XFFCFA904),
    secondary: Color(0XFF007FB1),
    success: : Color(0XFF5AB009),
    info: : Color(0XFF1283B0),
    warning: : Color(0XFFFCC319),
    error: : Color(0XFFB03009),
    brightness: Brightness.dark,
);

Authors

Exemple

////////// IMPORT EASY THEME //////////
import 'package:easy_theme/easy_theme.dart';

/// Creating a Easy Theme based on the blue color (`Colors.blue`)
final EasyTheme myCustomTheme = EasyTheme(primary: Colors.blue);

/// get the ThemeData object created by the EasyTheme
final ThemeData myTheme = myCustomTheme.getTheme();

/// get the EasyColors object created by the EasyTheme
final EasyColors myColors = myCustomTheme.getColors();

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Theme Test',
      /// use `myTheme` in your
      theme: myTheme,
      home: MyHomePage(),
    );
  }
}

easy_theme's People

Watchers

 avatar  avatar

Forkers

yarocabbage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.