conceptadev / mix

A styling system for Flutter
https://fluttermix.com
BSD 3-Clause "New" or "Revised" License
601 stars 37 forks source link

feat: Fluent API #475

Closed leoafarias closed 2 months ago

leoafarias commented 2 months ago

Related issue

This pull request is not directly related to any open issues.

Description

This pull request introduces support for a fluent API in the Mix library. The fluent API allows for more expressive and readable code when working with Mix specifications and utilities. It enables chaining of method calls and provides a more intuitive way to configure and build Mix components.

The fluent API support brings the following improvements:

Changes

The key changes made in this pull request include:

The fluent API allows developers to chain method calls and build Mix components in a more expressive and readable manner. For example:

final box = BoxSpecUtility.self;

final util = box.chain
  ..alignment.center()
  ..padding(8);

final style = Style(util);

In the above code snippet, the chain getter is used to create a mutable BoxSpecUtility instance, and the fluent methods alignment.center() and padding(8) are chained to configure the box specification.

The tests added in this pull request ensure the correctness and expected behavior of the fluent API across different Mix specifications.

Please review the changes and provide any feedback or suggestions for improvement.

Review Checklist

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **mix-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/fluttertools/mix-docs/EpVTBTGGQreF4FVLQ8MiN7CZHFrS)) | [Visit Preview](https://mix-docs-git-feat-new-fluent-api-fluttertools.vercel.app) | | Sep 3, 2024 2:11pm |