rlstyles 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

rlStyle #

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

demo演示视频 #

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

使用 #

翻墙原因 上传pub有问题 可以使用git方式 添加rlStyle到您的pubspec.yaml

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

示例 #

示例代码 请直接运行本地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 #

名称类型参数写法
displayStringflex,none
colordynamicColors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
flexDirectionStringrow,column
justifyContentStringflex-start,center,flex-end,space-between,space-arround,space-evenly
alignItemsStringflex-start,center,flex-end,space-between,space-arround,space-evenly
flexintflex:1

box-size #

名称类型参数写法
widthdynamicString,int,double,'16px'
heightdynamicString,int,double,'16px'
maxWidthdoublemaxWidth:100
maxHeightdoublemaxHeight:100
minHeightdoubleminHeight:100
minWidthdoubleminWidth:100
margindoublemargin:100
marginLeftdoublemarginLeft:100
marginTopdoublemarginTop:100
marginRightdoublemarginRight:100
marginBottomdoublemarginBottom:100
paddingdoublepadding:100
paddingLeftdoublepaddingLeft:100
paddingTopdoublepaddingTop:100
paddingRightdoublepaddingRight:100
paddingBottomdoublepaddingBottom:100

box #

名称类型参数写法
opacitydoubleopacity:1.0

border #

名称类型参数写法
borderRadiusdoubleborderRadius:10
borderWidthdoubleborderWidth:1
borderStyleStringsolid
borderColordynamicColors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
boxShadowdynamic[BoxShadow(offset:Offset(0,1))],BoxShadow(offset:Offset(0,1))
elevationdoubleelevation:10
borderBottomLeftRadiusdoubleborderBottomLeftRadius:10
borderBottomRightRadiusdoubleborderBottomRightRadius:10
borderTopLeftRadiusdoubleborderTopLeftRadius:10
borderTopRightRadiusdoubleborderTopRightRadius:10
borderLeftStyleStringsolid
borderLeftColordynamicColors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
borderLeftWidthdoubleborderLeftWidth:10
borderRightStyleStringsolid
borderRightColorStringsolid
borderRightWidthdoubleborderRightWidth:1.0
borderTopStyleStringsolid
borderTopColordynamicColors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
borderTopWidthdoubleborderTopWidth:1.0
borderBottomWidthdoubleborderBottomWidth:1.0
borderBottomColordynamicColors.white,Color(0xFFFFFF),rgba(255,255,255,1),rgb(255,255,255),white
borderBottomStyleStringsolid

postion #

名称类型参数写法
leftdoubleleft:10
rightdoubleright:10
topdoubletop:10
bottomdoublebottom:10
positionStringrel,relative,abs,absolute,(rel = relative abs = absolute),grid

background #

名称类型参数写法
backgroundImagestringlinear-gradient(rgba,rgb,white)
backgroundColordynamiclinear-gradient(rgba,rgb,white),Colors.white,Color(0xFFFFFF),rgba(255,255,
255,1),rgb(255,255,255),white

font #

名称类型参数写法
fontWeightdynamic100,200,300,400,500,600,700,800,900,bold
fontFamilyStringfontFamily:'微软雅黑'
fontSizedoublefontSize:10
textDecorationStringnone overline line-through underline
textOverflowStringclip ellipsis string
textAlignStringstart left center right justify

scroll #

名称类型参数写法
overflowStringscroll 纵向滑动
overflowYStringscroll 纵向滑动
overflowXStringscroll 横向滑动

grid #

名称类型参数写法
gridCountint一行子元素数量
gridMainAxisSpacingdouble主轴上下间距
gridCrossAxisSpacingdouble副轴上下间距
gridChildAspectRatiodouble子元素比例

暂不支持属性 #

boxSizing lineHeight whiteSpace lines letterSpacing

1.0.1 #

  • 1.增加zIndex
  • 2.增加flexrap案例

1.0.2 #

  • 1.修复滚动Bug

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  rlstyles: ^1.0.2

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:rlstyles/Component/ContainerView.dart';
import 'package:rlstyles/Component/HexColor.dart';
import 'package:rlstyles/Component/ImageView.dart';
import 'package:rlstyles/Component/ScrollView.dart';
import 'package:rlstyles/Component/Styles.dart';
import 'package:rlstyles/Component/TextView.dart';
import 'package:rlstyles/Component/View.dart';
import 'package:rlstyles/Router/StackRouter.dart';
import 'package:rlstyles/Tool/Tool.dart';
import 'package:rlstyles/Tool/base.dart';
import 'package:rlstyles/main.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/Component/ContainerView.dart. (-1 points)

Analysis of lib/Component/ContainerView.dart reported 2 hints:

line 55 col 56: Dead code.

line 55 col 56: Avoid empty statements.

Fix lib/Component/HexColor.dart. (-0.50 points)

Analysis of lib/Component/HexColor.dart reported 1 hint:

line 42 col 18: The value of the local variable 'direction' isn't used.

Format lib/Component/ImageView.dart.

Run flutter format to format lib/Component/ImageView.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/Component/ScrollView.dart (Run flutter format to format lib/Component/ScrollView.dart.)
  • lib/Component/Styles.dart (Run flutter format to format lib/Component/Styles.dart.)
  • lib/Component/TextView.dart (Run flutter format to format lib/Component/TextView.dart.)
  • lib/Component/View.dart (Run flutter format to format lib/Component/View.dart.)
  • lib/Router/StackRouter.dart (Run flutter format to format lib/Router/StackRouter.dart.)
  • lib/Tool/Tool.dart (Run flutter format to format lib/Tool/Tool.dart.)
  • lib/Tool/base.dart (Run flutter format to format lib/Tool/base.dart.)
  • lib/main.dart (Run flutter format to format lib/main.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (flutter_screenutil).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flutter 0.0.0
flutter_screenutil ^0.6.0 0.6.1 1.0.2
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test