goya 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new47

goya #

Goya is a style/theme manager for Flutter apps.

Usage #

Goya reads your style traits from a YAML file named goya.yaml. Either pre-define this file wherever you want or fetch it over a network request.

Setting up Goya

You need to use GoyaProvider as the root widget of your application. Simply set the path to your goya.yaml (you might fetch it over a network request then save to a file) and you are good to go.

GoyaProvider(path: "assets/goya.yaml", child: MyHomePage(title: 'Goya Demo')),

Theming using Goya

After setting up, all you need to do is tell Goya which key it will use for a specific widget and it takes care of the rest!

//Keys.text is just a string ".Text" in this example
//Goya reads the predefined variables under the root key ".Text"
//You can define different style traits such as ".TextPrimary", ".TextHeader" etc. in goya.yaml
Text("Goya").goya(key: Keys.text))

Overriding the goya.yaml

If you wish to override some property you can just set it as usual;

//Here we are overriding the TextAlign value to .left even though it is predefined as .center in our goya.yaml
Text("Goya", textAlign: TextAlign.left).goya(key: Keys.text)

Theme/Style Custom Widgets #

If you have a custom widget or a widget that Goya doesn't support natively you can easily implement necessary styling functions.

First, create a class that extends to StyleIdentifier and name your custom property.

class CustomStyleIdentifier extends StyleIdentifier {
  static const String customProperty = ".customProperty";

Then we need to create another class which extends GoyaBuilderStrategy<YOUR_CUSTOM_WIDGET>

class CustomWidgetGoyaBuilder extends GoyaBuilderStrategy<CustomWidget> {
  Widget build(CustomWidget originalWidget, {ThemeSymbol using}) {
    Color color = Color(
        finder(using.identifier, CustomStyleIdentifier.customProperty));
    CustomWidget goyaContainer = CustomWidget(color: color);
    return originalWidget.toGoya(goyaContainer).preparePaint(using);

Lastly, create an extension method for your custom widget.

extension CustomWidgetExtension on CustomWidget {
  CustomWidget toGoya(CustomWidget goyaWidget) {
    return CustomWidget(color: color ?? goyaWidget.color);

Example goya.yaml

#pre-define the colors
  - &orange
  - &blue

  .align: center
  .color: *blue
  .backgroundColor: *orange
  .fontSize: 48.0
  .fontWeight: 8
  .letterSpacing: 0.1
  .wordSpacing: 0.2
  .fontFamily: Pacifico
  .padding: [8.0, 16.0, 8.0, 16.0]

  .color: *blue

  .customProperty: *orange

[0.1.0] - TODO: Add release date. #

  • initial release.


import 'package:example/custom_widget.dart';
import 'package:flutter/material.dart';
import 'package:goya/goya.dart';
import 'keys.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      home: GoyaProvider(
          path: "assets/goya.yaml", child: MyHomePage(title: 'Goya Demo')),

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

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
                .goya(key: Keys.custom, builder: CustomWidgetGoyaBuilder()),
              child: Text("Goya").goya(key: Keys.text),
              height: 200,
              width: 200,
            ).goya(key: Keys.container)

Use this package as a library

1. Depend on it

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

  goya: ^0.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.

3. Import it

Now in your Dart code, you can use:

import 'package:goya/goya.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-0.42 points)

50 out of 51 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

The package description is too short. (-12 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
yaml ^2.2.0 2.2.0
Transitive dependencies
charcode 1.1.3
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies