2 Star 0 Fork 1

fangkyi03 / flutter-rlstyles

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

rlStyle

可以使用类似 rn 的写法类写 flutter 减少 flutter 的地狱嵌套

demo 演示视频

https://www.bilibili.com/video/av71131117


tailwindcss 语法 https://www.bilibili.com/video/BV1U34y187As/

注意事项

1.不要再 root 级 使用 flex:1 这样会导致报错 debug 模式正常 但是 profile release 都会无法正常显示

使用

添加 rlStyle 到您的 pubspec.yaml

dependencies:
  rlstyles: 2.0.1

示例

示例代码 请直接运行本地 example 项目 内涵 9 个小 demo 增加 grid 案例

demo

import 'package:flutter/material.dart';
import 'package:rlstyles/Router.dart';
import 'package:rlstyles/Styles.dart';
import 'package:rlstyles/View.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class Demo1 extends StatelessWidget {

  const Demo1({this.navigation});
  final NavigationOption navigation;

  renderView () {
    List<dynamic> colorArr = ['blue','red','#f55fff','rgba(255,12,13,1)','rgb(12,5,78)',Colors.red,Colors.black.withOpacity(0.5),'linear-gradient(blue,red)'];
    return View(
      styles: styles['wrap'],
      children: colorArr.map((f){
        return View(
          styles: Styles(
            width: 300,
            height: 300,
            marginTop: 50,
            marginLeft: 50,
            marginRight: 10,
            backgroundColor: f
          ),
        );
      }).toList(),
    );
  }

  @override
  Widget build(BuildContext context) {
    // 在整个项目初始化的地方 只需要初始化一次 填入设计稿尺寸即可
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1330);
    return View(
      styles: styles['main'],
      children: <Widget>[
        renderView()
      ],
    );
  }
}

const Map<String,Styles> styles = {
  'main':Styles(
    flexDirection: 'column',
    backgroundColor: 'white',
    overflow: 'scroll',
    width: double.infinity,
    height: double.infinity,
    paddingBottom: 100
  ),
  'wrap':Styles(
    flexWrap: 'wrap',
    position: 'rel'
  )
};

flex

名称 类型 参数写法
display String flex,none
color dynamic Colors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
flexDirection String row,column
justifyContent String flex-start,center,flex-end,space-between,space-arround,space-evenly
alignItems String flex-start,center,flex-end,space-between,space-arround,space-evenly
flex int flex:1

box-size

名称 类型 参数写法
width dynamic String,int,double,'16px'
height dynamic String,int,double,'16px'
maxWidth double maxWidth:100
maxHeight double maxHeight:100
minHeight double minHeight:100
minWidth double minWidth:100
margin double margin:100
marginLeft double marginLeft:100
marginTop double marginTop:100
marginRight double marginRight:100
marginBottom double marginBottom:100
padding double padding:100
paddingLeft double paddingLeft:100
paddingTop double paddingTop:100
paddingRight double paddingRight:100
paddingBottom double paddingBottom:100

box

名称 类型 参数写法
opacity double opacity:1.0

border

名称 类型 参数写法
borderRadius double borderRadius:10
borderWidth double borderWidth:1
borderStyle String solid
borderColor dynamic Colors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
boxShadow dynamic [BoxShadow(offset:Offset(0,1))],BoxShadow(offset:Offset(0,1))
elevation double elevation:10
borderBottomLeftRadius double borderBottomLeftRadius:10
borderBottomRightRadius double borderBottomRightRadius:10
borderTopLeftRadius double borderTopLeftRadius:10
borderTopRightRadius double borderTopRightRadius:10
borderLeftStyle String solid
borderLeftColor dynamic Colors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
borderLeftWidth double borderLeftWidth:10
borderRightStyle String solid
borderRightColor String solid
borderRightWidth double borderRightWidth:1.0
borderTopStyle String solid
borderTopColor dynamic Colors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
borderTopWidth double borderTopWidth:1.0
borderBottomWidth double borderBottomWidth:1.0
borderBottomColor dynamic Colors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
borderBottomStyle String solid

postion

名称 类型 参数写法
left double left:10
right double right:10
top double top:10
bottom double bottom:10
position String rel,relative,abs,absolute,(rel = relative abs = absolute),grid

background

名称 类型 参数写法
backgroundImage string linear-gradient(rgba,rgb,white)
backgroundColor dynamic linear-gradient(rgba,rgb,white),Colors.white,Color(0xFFFFFF),rgba(255,255,

255,1),rgb(255,255,255),white

font

名称 类型 参数写法
fontWeight dynamic 100,200,300,400,500,600,700,800,900,bold
fontFamily String fontFamily:'微软雅黑'
fontSize double fontSize:10
textDecoration String none overline line-through underline
textOverflow String clip ellipsis string
textAlign String start left center right justify

scroll

名称 类型 参数写法
overflow String scroll 纵向滑动
overflowY String scroll 纵向滑动
overflowX String scroll 横向滑动

grid

名称 类型 参数写法
gridCount int 一行子元素数量
gridMainAxisSpacing double 主轴上下间距
gridCrossAxisSpacing double 副轴上下间距
gridChildAspectRatio double 子元素比例

暂不支持属性

boxSizing lineHeight whiteSpace lines letterSpacing

BSD 2-Clause License Copyright (c) 2018, Quirijn Groot Bluemink All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

暂无描述 展开 收起
BSD-2-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/fangkyi03/flutter-rlstyles.git
git@gitee.com:fangkyi03/flutter-rlstyles.git
fangkyi03
flutter-rlstyles
flutter-rlstyles
master

搜索帮助