flutter_sujian_select 1.0.1

flutter_select #

一次学习Flutter的过程,一个简单的单选或者多选。

截图 #

截图

导入 #

flutter_sujian_select:^1.0.1
import 'package:flutter_sujian_select/flutter_select.dart';

##使用

单选

SelectGroup<int>(
              index:0,
              items: <SelectItem<int>>[
                SelectItem(label: '30天',value: 1),
                SelectItem(label: '60天',value: 2),
                SelectItem(label: '90天',value: 3),
              ],
              onSingleSelect: (int value){
              
              },
            ),

多选

SelectGroup<int>(
              type: SelectType.multiple,
              style: SelectStyle.rectangle,
              direction: SelectDirection.vertical,
              listIndex: [1,2],
              items: <SelectItem<int>>[
                SelectItem(label: '1',value: 1),
                SelectItem(label: '2',value: 2),
                SelectItem(label: '3',value: 3),
                SelectItem(label: '4',value: 4),
              ],
              onMultipleSelect: (List<int> value){
             
              },
            ),

属性说明 #

属性描述默认值
borderColor边框颜色Colors.blue
unSelectColor未选中背景颜色Colors.white
selectColor选中颜色Colors.blue
spaceitem之间的距离const EdgeInsets.all(0.0)
padding内边距const EdgeInsets.all(8.0)
isRepeatBorderLine是否去掉重复的线(矩形生效)false
type选择类型SelectType.single
styleitem风格SelectStyle.circular
direction排列方向SelectDirection.horizontal
index默认值(单选可用)null
listIndex默认值(多选可用)null
onSingleSelect单选回调(单选可用)null
onMultipleSelect多选回调(单选可用)null
items选项(必要)null

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_sujian_select/flutter_select.dart';



void main() => runApp(App());

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: HomePage());
  }
}

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
  var _scaffoldkey = new GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldkey,
      appBar: AppBar(
        title: Text('Select'),
      ),
      body: Container(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SelectGroup<int>(
              items: <SelectItem<int>>[
                SelectItem(label: '30天', value: 1),
                SelectItem(label: '60天', value: 2),
                SelectItem(label: '90天', value: 3),
              ],
              onSingleSelect: (int value) {
                _scaffoldkey.currentState
                    .showSnackBar(SnackBar(content: Text(value.toString())));
              },
            ),
            SizedBox(
              height: 20,
            ),
            SelectGroup<String>(
              style: SelectStyle.rectangle,
              items: <SelectItem<String>>[
                SelectItem(label: '一', value: '一'),
              ],
              onSingleSelect: (String value) {
                _scaffoldkey.currentState
                    .showSnackBar(SnackBar(content: Text(value.toString())));
              },
            ),
            SizedBox(
              height: 20,
            ),
            SelectGroup<String>(
              style: SelectStyle.rectangle,
              items: <SelectItem<String>>[
                SelectItem(label: '一', value: '一'),
                SelectItem(label: '二', value: '二'),
              ],
              onSingleSelect: (String value) {
                _scaffoldkey.currentState
                    .showSnackBar(SnackBar(content: Text(value.toString())));
              },
            ),
            SizedBox(
              height: 20,
            ),
            SelectGroup<String>(
              style: SelectStyle.rectangle,
              items: <SelectItem<String>>[
                SelectItem(label: '一', value: '一'),
                SelectItem(label: '二', value: '二'),
                SelectItem(label: '三', value: '三'),
                SelectItem(label: '三', value: '三'),
              ],
              onSingleSelect: (String value) {
                _scaffoldkey.currentState
                    .showSnackBar(SnackBar(content: Text(value.toString())));
              },
            ),
            SizedBox(
              height: 20,
            ),
            SelectGroup<int>(
              space: EdgeInsets.all(8.0),
              type: SelectType.multiple,
              listIndex: [2],
              items: <SelectItem<int>>[
                SelectItem(label: '1', value: 1),
                SelectItem(label: '2', value: 2),
                SelectItem(label: '3', value: 3),
                SelectItem(label: '4', value: 4),
              ],
              onMultipleSelect: (List<int> value) {
                _scaffoldkey.currentState
                    .showSnackBar(SnackBar(content: Text(value.toString())));
              },
            ),
            SizedBox(
              height: 20,
            ),
            SelectGroup<int>(
              type: SelectType.multiple,
              style: SelectStyle.rectangle,
              direction: SelectDirection.vertical,
              listIndex: [1, 2],
              items: <SelectItem<int>>[
                SelectItem(label: '1', value: 1),
                SelectItem(label: '2', value: 2),
                SelectItem(label: '3', value: 3),
                SelectItem(label: '4', value: 4),
              ],
              onMultipleSelect: (List<int> value) {
                _scaffoldkey.currentState
                    .showSnackBar(SnackBar(content: Text(value.toString())));
              },
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_sujian_select: ^1.0.1

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:flutter_sujian_select/flutter_select.dart';
import 'package:flutter_sujian_select/select_group.dart';
import 'package:flutter_sujian_select/select_item.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
74
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

Document public APIs. (-0.41 points)

49 out of 50 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_select.dart.

Run flutter format to format lib/flutter_select.dart.

Format lib/select_item.dart.

Run flutter format to format lib/select_item.dart.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
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