Skip to content

Commit 22e780b

Browse files
committed
refactor(actionsheet): modify the context as a required parameter
1 parent 29d4ac1 commit 22e780b

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

example/lib/action_sheet_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ActionSheetExample extends StatelessWidget {
77
appBar: AppBar(title: Text("ActionSheet"),),
88
body: Center(
99
child: FlatButton(onPressed: (){
10-
ActionSheet.show(context: context,data:["Item1","Item2","Item3"]);
10+
ActionSheet.show(context,data:["Item1","Item2","Item3"]);
1111
}, child: Text("ActionSheet")),
1212
),
1313
);

example/lib/cell_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CellExample extends StatelessWidget {
3636
secondaryText: "说明文字",
3737
onPressed: () {
3838
ActionSheet.show(
39-
context: context,
39+
context,
4040
data: ["1", "3", "sdfs"],
4141
onPress: (details) {
4242
print(details.toString());

example/lib/picker_example.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_weui/flutter_weui.dart';
3+
class DialogExample extends StatelessWidget {
4+
@override
5+
Widget build(BuildContext context) {
6+
return Scaffold(
7+
appBar: AppBar(title: Text("Dialog"),),
8+
body: Center(
9+
child: Column(
10+
children: <Widget>[
11+
FlatButton(onPressed: (){
12+
WDialog.show(context,title: "Title",content: "Context",actions: [
13+
DialogActions(text: "取消"),
14+
DialogActions(text: "确定")
15+
]);
16+
}, child: Text("Dialog_Android")),
17+
FlatButton(onPressed: (){
18+
WDialog.show(context,title: "Title",content: "Context",actions: [
19+
DialogActions(text: "取消"),
20+
DialogActions(text: "确定")
21+
],platform: TargetPlatform.iOS);
22+
}, child: Text("Dialog_Ios"))
23+
],
24+
),
25+
),
26+
);
27+
}
28+
}

lib/action_sheet.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22

33
class ActionSheetPressDetails {
44
ActionSheetPressDetails({this.index, this.text});
5+
56
final int index;
67
final String text;
78

@@ -16,8 +17,8 @@ typedef ActionSheetPressVoidCallBack = void Function(ActionSheetPressDetails det
1617
///展示手机action
1718
class ActionSheet {
1819
///展示ActionSheet
19-
static show({
20-
BuildContext context,
20+
static show(
21+
BuildContext context, {
2122
List<String> data,
2223
ActionSheetPressVoidCallBack onPress,
2324
Color containerColor = const Color(0xEFEFF4),
@@ -60,7 +61,7 @@ class ActionSheet {
6061
}
6162

6263
class _Cell extends StatefulWidget {
63-
_Cell({Key key, this.text, this.onPressed,this.textColor}) : super(key: key);
64+
_Cell({Key key, this.text, this.onPressed, this.textColor}) : super(key: key);
6465

6566
final String text;
6667
final VoidCallback onPressed;

lib/cells.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class _CellSelectState extends State<CellSelect> {
5454

5555
_handleTap(BuildContext context) {
5656
ActionSheet.show(
57-
context: context,
57+
context,
5858
data: widget.options,
5959
onPress: (detail) {
6060
setState(() {

0 commit comments

Comments
 (0)