base 0.1.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 54

logo

实现一套代码,2种模式,ios使用Cupertino风格组件,andriod、fuchsia使用Material风格组件 #

English #

当前只针对Cupertino模式进行了测试,Material组件相对比较完善了,后期也会补上Material模式的测试。 #

基础类 #

  • BaseStatelessWidget

    继承于StatelessWidget,用于构建无状态组件

    子类必须实现 buildByCupertino、buildByMaterial 方法,分别用于构建2种模式

  • BaseStatefulWidget

    继承于StatefulWidget,用于构建状态组件

    子类的State类必须继承 BaseState 类并实现 buildByCupertino、buildByMaterial 方法,分别用于构建2种模式

  • BaseClass

    普通基础类,用于构建普通类

    子类必须实现 buildByCupertino、buildByMaterial 方法分别用于构建2种模式

  • basePlatform 参数

    当前构建的平台,默认为 defaultTargetPlatform

    使用 setPlatform(TargetPlatform targetPlatform) 方法修改平台

    推荐使用 BaseApp(targetPlatform: TargetPlatform...) 设置平台

    默认 TargetPlatform.iOS 使用 Cupertino 构建, TargetPlatform.androidTargetPlatform.fuchsia 使用 Material 构建

Features #

  • useCupertino, useMaterial 使用这2个方法可以判断当前使用的模式,进行差异化构建。

  • 每个基础组件都含有 Map<String, dynamic> cupertino, Map<String, dynamic> material 2个参数,用于组件模式差异化设置,2种模式有公共参数的,会优先取当前模式下的值,再取公共值,如:

    BaseIcon(
      // materil模式下先取material参数里的icon参数,取不到再取该值
      icon: Icons.info,
      cupertino: <String, dynamic>{
        // cupertino模式下先取该值,因为取得到,所以不会取外层的icon
        'icon': CupertinoIcons.info,
      }
    );
    

    cupertino模式下使用的是CupertinoIcons.info,material模式下使用的是Icons.info

    features_demo
  • 可以使用 forceUseMaterial, forceUseCupertino 进行强制切换模式构建,使用 disabled 禁止构建(会用 Container() 代替)

    cupertino: {
      // 可使该组件强制使用Material构建
      forceUseMaterial: true,
      // 可使该组件不进行构建,但会使用Container()代替
      disabled: true,
    }
    material: {
      // 可使该组件强制使用Cupertino构建
      forceUseCupertino: true,
      // 可使该组件不进行构建,但会使用Container()代替
      disabled: true,
    }
    
  • 特别说明,非常重要 #

    forceUseMaterial, forceUseCupertino 参数未经严格测试,请慎用!慎用!慎用!

    很多material组件是需要有Material祖先的,在Cupertino模式下设置forceUseMaterial: true时,会默认套上一层Material,且默认会去除水波纹效果,此时BaseApp上的cupertinoTheme参数是不生效的,可能会出现样式混乱等不可预知的bug,所以请慎用,后续可能会删除这2个参数

    如果要切换模式,强烈建议直接设置BaseApp's targetPlatform参数 #

组件列表 #

组件Material组件Cupertino组件
BaseActionSheetcustom BottomSheetCupertinoActionSheet
BaseActionSheetActionFlatButtonCupertinoActionSheetAction
BaseAppMaterialAppCupertinoApp
BaseAppBarAppBarCupertinoNavigationBar
BaseButtonMaterialButton
FlatButton, FlatButton.icon
OutlineButton, OutlineButton.icon
RaisedButton, RaiseButton.icon
CupertinoButton, CupertinoButton.filled
BaseIconButtonIconButtonCupertinoButton
BaseAlertDialogAlertDialogCupertinoAlertDialog
BaseDialogActionFlatButtonCupertinoDialogAction
BaseIconIconIcon
BaseIndicatorCircularProgressIndicatorCupertinoActivityIndicator
BaseRefreshRefreshIndicatorCustomScrollView + CupertinoSliverRefreshControl
BaseScaffoldScaffoldCupertinoPageScaffold
BaseTabScaffoldScaffoldCupertinoTabScaffold
BaseScrollBarScrollBarCupertinoScrollBar
BaseSectioncustom Containercustom Container
BaseTileListTilecustom InkWell without splash
BaseSliderSliderCupertinoSlider
BaseSwitchSwitchCupertinoSwitch
BaseBarItemBottomNavigationBarItemBottomNavigationBarItem
BaseTabBarBottomNavigationBarCupertinoTabBar
BaseTextFieldTextFieldCupertinoTextField

简单示例 #

0.1.9 - 2019.05.02 #

  • Release v0.1.9
  • modify CupertinoTabBar, CupertinoTabScaffold, BottomNavigationBar, BottomNavigationBarItem
  • BottomNavigationBarItem's icon can be null.

0.1.8 - 2019.04.28 #

  • Release v0.1.8
  • add BaseTextField
  • add example's screenshot

0.1.7 - 2019.04.26 #

  • Release v0.1.7
  • add BaseActionSheet
  • fix BaseTabScaffold

0.1.6 - 2019.04.25 #

  • Release v0.1.6
  • change cupertino,material to Map<String, dynamic>

0.1.5 - 2019.04.24 #

  • Release v0.1.5

0.1.4 - 2019.04.24 #

  • Release v0.1.4

0.1.3 - 2019.04.23 #

  • Release v0.1.3
  • add routes demo
  • add refresh demo
  • improve the document
  • change the default README.md to Chinese

0.1.2 - 2019.04.23 #

  • Release v0.1.2
  • fix BaseAppBar's bug
  • add alert dialog demo
  • add button demo

0.1.1 - 2019.04.21 #

  • Release v0.1.1
  • add analysis_options.yaml

0.1.0 - 2019.04.20 #

  • Release v0.1.0

0.0.3 - 2019.04.19 #

  • Release v0.0.3

0.0.2 - 2019.04.19 #

  • Release v0.0.2

0.0.1 - 2019.04.16 #

  • Release v0.0.1

example/README.md

logo

简单示例(模拟器:iPhone Xs Max 12.2、Nexus_5X android 8.0.0) #

home_cupertino home_material

BaseAppBar #

height #

appBar_height_cupertino appBar_height_material

bottom #

appBar_bottom_cupertino appBar_bottom_material

toolbarOpacity #

appBar_toolbarOpacity_cupertino

backdropFilter #

appBar_backdropFilter_cupertino

Scaffold #

safeArea scaffold #

scaffold_safeArea_cupertino

tab scaffold #

scaffold_tabScaffold_cupertino scaffold_tabScaffold_material

Section & Tile

section_wechat_cupertino section_wechat_material

Button #

button_cupertino button_material

Route #

routes_cupertino routes_material

Alert Dialog #

alertDialog_cupertino alertDialog_material

Action Sheet #

actionSheet_cupertino actionSheet_material

Refresh #

refresh_cupertino refresh_material

Text Field #

textField_cupertino textField_material

Use this package as a library

1. Depend on it

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


dependencies:
  base: ^0.1.9

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:base/base.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
35
Health:
Code health derived from static analysis. [more]
56
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Health issues and suggestions

Fix lib/flutter/cupertino/nav_bar.dart. (-44.03 points)

Analysis of lib/flutter/cupertino/nav_bar.dart failed with 2 errors, 1 hint:

line 524 col 13: The argument type 'TransitionBuilderWidget Function(BuildContext, Widget)' can't be assigned to the parameter type 'Widget Function(BuildContext, Size, Widget)'.

line 901 col 7: The argument type 'TransitionBuilderWidget Function(BuildContext, Widget)' can't be assigned to the parameter type 'Widget Function(BuildContext, Size, Widget)'.

line 2427 col 66: This function has a return type of '_NavigationBarTransition', but doesn't end with a return statement.

Format lib/flutter/cupertino/bottom_tab_bar.dart.

Run flutter format to format lib/flutter/cupertino/bottom_tab_bar.dart.

Format lib/flutter/cupertino/tab_scaffold.dart.

Run flutter format to format lib/flutter/cupertino/tab_scaffold.dart.

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/flutter/material/app_bar.dart (Run flutter format to format lib/flutter/material/app_bar.dart.)
  • lib/flutter/material/bottom_navigation_bar.dart (Run flutter format to format lib/flutter/material/bottom_navigation_bar.dart.)
  • lib/flutter/widgets/bottom_navigation_bar_item.dart (Run flutter format to format lib/flutter/widgets/bottom_navigation_bar_item.dart.)
  • lib/scaffold/base_tab_scaffold.dart (Run flutter format to format lib/scaffold/base_tab_scaffold.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.5.0