自研flutter[rlstyles] UI框架發(fā)布

rlStyle

可以使用類似rn的寫法類寫flutter 減少flutter的地獄嵌套

備注

flutter pub 因?yàn)榉瓑﹃P(guān)系 導(dǎo)致一直無法上傳成功 所以只能改用git方式集成

項(xiàng)目地址

https://github.com/fangkyi03/rlstyle.git

demo演示視頻

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

使用

添加rlStyle到您的pubspec.yaml

dependencies:
  flutter_screenutil: ^0.5.3
  rlstyles:
    git:
      url: git://github.com/fangkyi03/rlstyle.git

示例

示例代碼 請(qǐng)直接運(yùn)行本地example項(xiàng)目 內(nèi)涵9個(gè)小demo

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) {
    // 在整個(gè)項(xiàng)目初始化的地方 只需要初始化一次 填入設(shè)計(jì)稿尺寸即可
    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

名稱 類型 參數(shù)寫法
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

名稱 類型 參數(shù)寫法
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

名稱 類型 參數(shù)寫法
opacity double opacity:1.0

border

名稱 類型 參數(shù)寫法
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

名稱 類型 參數(shù)寫法
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)

background

名稱 類型 參數(shù)寫法
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

名稱 類型 參數(shù)寫法
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

名稱 類型 參數(shù)寫法
overflow String scroll 縱向滑動(dòng)
overflowY String scroll 縱向滑動(dòng)
overflowX String scroll 橫向滑動(dòng)

暫不支持屬性

boxSizing
lineHeight
whiteSpace
lines
letterSpacing

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 記得去年9月份的時(shí)候谷歌在上海有一次開發(fā)者大會(huì),去參加的時(shí)候關(guān)注到了flutter,隨后沒過多久就發(fā)布了1.0版本...
    炸雞叔閱讀 25,106評(píng)論 9 64
  • 沙揚(yáng)娜拉的手鏈 樅陽中學(xué)401班 錢汝菲 書桌上擺著一條紅繩編成的手鏈,上面除了顆仿白玉的珠子外,什么都沒有。燈光...
    春風(fēng)草堂閱讀 306評(píng)論 0 0
  • 原典: 作者: 西漢人,漢朝高祖劉邦之孫,名劉安。封淮南王(皇帝的親兒子兒孫才封王,屬貴族特權(quán)階層) 近塞上之人有...
    里里溪主筆閱讀 495評(píng)論 0 0
  • 一、異常處理 空指針訪問 試圖讀取不存在的文件 二、集合 集合是將多個(gè)對(duì)象組合在一起,對(duì)這些對(duì)象進(jìn)行存儲(chǔ)、檢索等操...
    降龍十八段閱讀 334評(píng)論 0 0
  • 你是一株草,孤單又渺小 經(jīng)歷過風(fēng)霜,仍然頑強(qiáng)生長(zhǎng) 你是一朵云,獨(dú)立又倔強(qiáng) 不知道下一站在哪...
    aha是sw閱讀 215評(píng)論 0 0

友情鏈接更多精彩內(nèi)容