1 Star 3 Fork 0

meetqy / flutter_tailwindcss

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

flutter_tailwindcss

体验用 tailwind 的方式去写 flutter 样式

温馨提示:体验一下就完事了,别真的用到项目上。

介绍

中文 | English

如何使用

dependencies:
  flutter_vant_kit: ^0.0.4

进度

doing name verison
🚀 done TwColor 0.0.2
🚀 done Spacing 0.0.3
👷 doing TwText -
👷 doing TwFont -
⏳ planing BorderRadius -
⏳ planing BorderWidth -
⏳ planing Divide -
⏳ planing Shadow -

基础属性

colors

spacing

但从属性上来看这是一个略显鸡肋的东西,在我个人写 demo 的时候发现了不能设置多个方向和不同数值。

后面会从复合型Widget上面考虑,这样结合起来,可能会更加实用。

复合型 Widget

TwText

TwTextTwFont 结合使用,TwText 相当于 flutter 中的 Text 只不过多了一个className参数。

tailwind对比一下

<p class="font-sans text-lg font-medium text-slate-900">
  The quick brown fox jumps over the lazy dog.
</p>

两种使用方式

第一种,通过TwText

TwText(
  'The quick brown fox jumps over the lazy dog.', className: [
  /// 文字等宽
  TwFont().sans,
  /// 文字大小 + 行高
  TwFont().text.lg,
  /// 文字颜色
  TwFont().slate.shade900,
  /// 加粗
  TwFont().medium
])

第二种,使用原生的Text,配合TextStyle扩展出来的 className 方法

Text(
  'The quick brown fox jumps over the lazy dog.',
  style: const TextStyle().className([
    TwFont().sans,
    TwFont().text.lg,
    TwFont().medium,
    TwFont().slate.shade900
  ]),
);

因为 TwFont 是一个类,所以无需安装插件,也可做到智能提示

可用属性

属性 用法 tailwind
Font Family TwFont().{family} font-family
Font Size TwFont().text.{size} font-size
Font Style TwFont().{style} font-style
Font Weight TwFont().{weight} font-weight
Letter Spacing TwFont().tracking.{spacing} letter-spacing
Line Height TwFont().leading.{height} line-height
Text Color TwFont().text.{color} text-color
Text Decoration TwFont().{decoration}, decoraiton.{colot}, decoraiton.{style}, decoraiton.{thickness} text-decoration

项目中的 demo

MIT License Copyright (c) [year] [fullname] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

体验用 tailwind 的方式去写 flutter 样式 展开 收起
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Dart
1
https://gitee.com/meetqy/flutter_tailwindcss.git
git@gitee.com:meetqy/flutter_tailwindcss.git
meetqy
flutter_tailwindcss
flutter_tailwindcss
main

搜索帮助