Skip to content

Commit 0475ded

Browse files
author
yangshangzhi
committed
feat:add scrollable demo
1 parent f73327a commit 0475ded

File tree

5 files changed

+55
-49
lines changed

5 files changed

+55
-49
lines changed

lib/components/widgetComp.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ class IndexState extends State<Index> {
9090
});
9191
}
9292

93-
openPage(context, model, String url) async {
93+
openPage(context, model) async {
94+
String url = this.mdUrl;
9495
// 加载页面
9596
if (model.config.state.isPro) {
9697
FluroRouter.router.navigateTo(context,
@@ -123,7 +124,7 @@ class IndexState extends State<Index> {
123124
Icons.code,
124125
),
125126
onPressed: () async {
126-
this.openPage(context, model, this.mdUrl);
127+
this.openPage(context, model);
127128
},
128129
),
129130
PopupMenuButton(

lib/widget/scrollview/index.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const nameSpaces = '/scrollview_';
88
List widgets = [
99
ItemInfo(
1010
widget: gridview.Index(),
11-
code: 59632, // view_module
11+
code: 58348, // grid_on
1212
title: gridview.Index.title,
1313
),
1414
ItemInfo(
@@ -18,7 +18,7 @@ List widgets = [
1818
),
1919
ItemInfo(
2020
widget: scrollable.Index(),
21-
code: 59631, // view_list
21+
code: 57920, // format_line_spacing
2222
title: scrollable.Index.title,
2323
)
2424
];

lib/widget/scrollview/scrollable/demo_custom_scrollview.dart

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,52 @@ class _IndexState extends State<Index> {
1414
@override
1515
Widget build(BuildContext context) {
1616
return Scrollable(
17-
axisDirection: AxisDirection.left,
18-
controller: ScrollController(),
19-
viewportBuilder: (context, offset) {
20-
return CustomScrollView(
21-
slivers: [
22-
SliverAppBar(
23-
pinned: true,
24-
expandedHeight: 250.0,
25-
flexibleSpace: FlexibleSpaceBar(
26-
title: Text('这里的标题会随着滚动向移'),
27-
),
17+
axisDirection: AxisDirection.left,
18+
controller: ScrollController(),
19+
viewportBuilder: (context, offset) {
20+
return CustomScrollView(
21+
slivers: [
22+
SliverAppBar(
23+
pinned: true,
24+
expandedHeight: 250.0,
25+
flexibleSpace: FlexibleSpaceBar(
26+
title: Text('这里的标题会随着滚动向上移'),
2827
),
29-
SliverGrid(
30-
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
31-
maxCrossAxisExtent: 200.0,
32-
mainAxisSpacing: 10.0,
33-
crossAxisSpacing: 10.0,
34-
childAspectRatio: 4.0,
35-
),
36-
delegate: SliverChildBuilderDelegate(
37-
(BuildContext context, int index) {
38-
return Container(
39-
alignment: Alignment.center,
40-
color: Colors.teal[100 * (index % 9)],
41-
child: Text('grid item $index'),
42-
);
43-
},
44-
childCount: 20,
45-
),
28+
floating: false,
29+
30+
),
31+
SliverGrid(
32+
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
33+
maxCrossAxisExtent: 200.0,
34+
mainAxisSpacing: 10.0,
35+
crossAxisSpacing: 10.0,
36+
childAspectRatio: 4.0,
4637
),
47-
SliverFixedExtentList(
48-
itemExtent: 50.0,
49-
delegate: SliverChildBuilderDelegate(
50-
(BuildContext context, int index) {
51-
return Container(
52-
alignment: Alignment.center,
53-
color: Colors.lightBlue[100 * (index % 9)],
54-
child: Text('list item $index'),
55-
);
56-
},
57-
childCount: 20
58-
),
38+
delegate: SliverChildBuilderDelegate(
39+
(BuildContext context, int index) {
40+
return Container(
41+
alignment: Alignment.center,
42+
color: Colors.teal[100 * (index % 9)],
43+
child: Text('grid item $index'),
44+
);
45+
},
46+
childCount: 20,
5947
),
60-
],
61-
);
62-
},
48+
),
49+
SliverFixedExtentList(
50+
itemExtent: 50.0,
51+
delegate:
52+
SliverChildBuilderDelegate((BuildContext context, int index) {
53+
return Container(
54+
alignment: Alignment.center,
55+
color: Colors.lightBlue[100 * (index % 9)],
56+
child: Text('list item $index'),
57+
);
58+
}, childCount: 20),
59+
),
60+
],
61+
);
62+
},
6363
);
6464
}
6565
}

lib/widget/scrollview/scrollable/demo.dart renamed to lib/widget/scrollview/scrollable/demo_single_child_scrollview.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class _IndexState extends State<Index> {
1414
@override
1515
Widget build(BuildContext context) {
1616
return Scaffold(
17+
appBar: AppBar(
18+
title: Text('SingleChildScrollView'),
19+
),
1720
body: Scrollable(
1821
viewportBuilder: (context, offset) {
1922
return Scrollable(

lib/widget/scrollview/scrollable/index.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3-
import 'demo.dart' as Demo;
3+
import 'demo_single_child_scrollview.dart' as DemoSingleChildScrollview;
4+
import 'demo_custom_scrollview.dart' as DemoCustomScrollview;
45

56
class Index extends StatefulWidget {
67
static String title = 'Scrollable';
@@ -19,7 +20,8 @@ class _IndexState extends State<Index> {
1920
originCodeUrl: Index.originCodeUrl,
2021
mdUrl: Index.mdUrl,
2122
demoChild: [
22-
Demo.Index(),
23+
DemoSingleChildScrollview.Index(),
24+
DemoCustomScrollview.Index(),
2325
]
2426
);
2527
}

0 commit comments

Comments
 (0)