Skip to content

Commit

Permalink
[flutter_web] Badge
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed May 17, 2024
1 parent 9edb6dc commit 33c5d32
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
10 changes: 5 additions & 5 deletions notes/flutter_web/lib/routes/notes/note.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
-`SliverAppBar``SliverList``SliverGrid` 等,专为`CustomScrollView`设计,用于高效实现滚动视图布局。
- **ShrinkWrappingViewport**:类似于ListView,但它的大小可以根据其子组件的大小进行收缩,而不是根据父容器的大小进行填充。

### 自定义相关
### 自定义布局

- **CustomSingleChildLayout**: 实现SingleChildLayoutDelegate自定义子组件的布局。
- **CustomMultiChildLayout**: 实现MultiChildLayoutDelegate自定义子组件的布局。
Expand Down Expand Up @@ -218,9 +218,6 @@
- **MenuBar**
- **PlatformMenuBar**
- **NavigationToolbar** is a layout helper to position 3 widgets or groups of widgets along a horizontal axis,正常应该使用带主题的Material AppBar or the iOS CupertinoNavigationBar
- **SnackBar**
- 【原理】ScaffoldMessenger.of(context).showSnackBar()
- **TextSelectionToolbar**
- **Sliver相关Bar**
- **SliverAppBar** 水平Bar,动画、可收缩的Bar
- **FlexibleSpaceBar**
Expand Down Expand Up @@ -283,7 +280,8 @@

- **Text**
- **Text.rich**
- RichText
- RichText
- **TextSelectionToolbar**
- Markdown
- SelectionArea 可选择界面一整个区域的文本
- DefaultTextStyle
Expand All @@ -292,6 +290,8 @@
- LinearProgressIndicator
- Badges [api-Badges](https://api.flutter.dev/flutter/material/Badge-class.html)
- **Tooltip**
- **SnackBar**
- 【原理】ScaffoldMessenger.of(context).showSnackBar()

### 滚动scrolling

Expand Down
60 changes: 36 additions & 24 deletions notes/flutter_web/lib/routes/notes/widgets/index/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,32 +281,44 @@ void build(BuildContext context, Cell print) {
});
}

Widget badgesCell(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Badge.count(count: 1000, child: const Icon(Icons.mail_outlined)),
const Badge(child: Icon(Icons.sms_failed_outlined)),
Badge.count(count: 23, child: ElevatedButton(onPressed: () {}, child: const Text("Button"))),
const Badge(
label: Text("2000 ¥"),
alignment: AlignmentDirectional.bottomCenter,
child: Card(
elevation: 4,
color: Colors.green,
child: Padding(padding: EdgeInsets.all(20), child: Text('Card')),
),
),
],
);
}

var all = Column(
children: [
Level1MasonryLayout(
title: "button&input&form",
cellWidth: 500,
children: [
CellView(title: "ButtonStyleButton", child: buttonStyleButtonCell(context)),
CellView(title: "FloatingActionButton", child: floatingActionButtonCell(context)),
CellView(title: "IconButton", child: iconButtonCell(context)),
CellView(title: "segmentButton", child: segmentButtonCell(context)),
],
),
Level1MasonryLayout(
title: "布局,Layout",
cellWidth: 500,
children: [
CellView(title: "Container", child: containerCell(context)),
],
),
Level1MasonryLayout(
title: "装饰器,Decorator",
cellWidth: 500,
children: [
CellView(title: "Card", child: cardCell(context)),
],
),
Level1MasonryLayout(title: "button&input&form", cellWidth: 500, children: [
CellView(title: "ButtonStyleButton", child: buttonStyleButtonCell(context)),
CellView(title: "FloatingActionButton", child: floatingActionButtonCell(context)),
CellView(title: "IconButton", child: iconButtonCell(context)),
CellView(title: "segmentButton", child: segmentButtonCell(context)),
]),
Level1MasonryLayout(title: "button&input&form", cellWidth: 400, children: [
CellView(title: "Badge", child: badgesCell(context)),
]),
//
Level1MasonryLayout(title: "布局,Layout", cellWidth: 500, children: [
CellView(title: "Container", child: containerCell(context)),
]),
Level1MasonryLayout(title: "装饰器,Decorator", cellWidth: 500, children: [
CellView(title: "Card", child: cardCell(context)),
]),
],
);

Expand Down

0 comments on commit 33c5d32

Please sign in to comment.