v5.0.1material_segmented_control
一个类似于 iOS 的分段控件,但采用 Material 设计。
103喜欢 1.1万近 30 天下载150Pub 分数
AndroidiOSWebmacOSWindowsLinux
具有完整行为和设计控制权的 Material 风格分段控件。
以下为英文项目原文快照,最新内容请访问 GitHub。
A material segmented control like the one for iOS, in Material style.
We all know well the Cupertino segmented widget in Flutter. But there is no similar in Material, so I thought, why not to create one.
You can check it out on pub.dev: (see package on pub.dev)
In your pubspec.yaml, add
dependencies:
material_segmented_control: ^5.0.1
Wherever you want to use this widget, import
import 'package:material_segmented_control/material_segmented_control.dart';
int _currentSelection = 0;
MaterialSegmentedControl(
children: _children,
selectionIndex: _currentSelection,
borderColor: Colors.grey,
selectedColor: Colors.redAccent,
unselectedColor: Colors.white,
selectedTextStyle: TextStyle(color: Colors.white),
unselectedTextStyle: TextStyle(color: Colors.redAccent),
borderWidth: 0.7,
borderRadius: 32.0,
disabledChildren: [3],
onSegmentTapped: (index) {
setState(() {
_currentSelection = index;
});
},
);
Map<int, Widget> _children = {
0: Text('Hummingbird'),
1: Text('Kiwi'),
2: Text('Rio'),
3: Text('Telluraves')
};
selectionIndex to null. It un-selects all options.onPressed to null on a button) by setting disabledChildren. Give it a list with all indices that should be disabled. Give it either null or an empty list to not use the disabled feature.You might want to check out the example project.
依赖清单 3 项
{"sdk":"flutter"}{"sdk":"flutter"}^2.0.1先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗