Skip to content

Commit d64ef4f

Browse files
committed
Add documentation
1 parent 5a4a73a commit d64ef4f

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

lib/src/alert_dialog.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import 'package:flutter/material.dart';
66
import 'extensions/extensions.dart';
77

88
/// Show alert dialog, whose appearance is adaptive according to platform
9+
///
10+
/// [useActionSheetForCupertino] (default: false) only works for
11+
/// cupertino style. If it is set to true, [showModalActionSheet] is called
12+
/// instead.
913
Future<T> showAlertDialog<T>({
1014
@required BuildContext context,
1115
String title,
@@ -87,6 +91,14 @@ Future<T> showAlertDialog<T>({
8791
);
8892
}
8993

94+
/// Show OK/Cancel alert dialog, whose appearance is adaptive according to platform
95+
///
96+
/// This is convenient wrapper of [showAlertDialog].
97+
/// [barrierDismissible] (default: true) only works for material style,
98+
/// and if it is set to false, pressing OK or Cancel buttons is only way to
99+
/// close alert.
100+
/// [defaultType] only works for cupertino style and if it is specified
101+
/// OK or Cancel button label will be changed to bold.
90102
Future<OkCancelResult> showOkCancelAlertDialog({
91103
@required BuildContext context,
92104
String title,
@@ -129,6 +141,11 @@ Future<OkCancelResult> showOkCancelAlertDialog({
129141
return result ?? OkCancelResult.cancel;
130142
}
131143

144+
/// Show OK alert dialog, whose appearance is adaptive according to platform
145+
///
146+
/// This is convenient wrapper of [showAlertDialog].
147+
/// [barrierDismissible] (default: true) only works for material style,
148+
/// and if it is set to false, pressing OK button is only way to close alert.
132149
Future<OkCancelResult> showOkAlertDialog({
133150
@required BuildContext context,
134151
String title,
@@ -155,6 +172,7 @@ Future<OkCancelResult> showOkAlertDialog({
155172
return result ?? OkCancelResult.cancel;
156173
}
157174

175+
/// Used for specifying [showAlertDialog]'s actions.
158176
@immutable
159177
class AlertDialogAction<T> {
160178
const AlertDialogAction({
@@ -173,13 +191,20 @@ class AlertDialogAction<T> {
173191

174192
/// Make font color to destructive/error color(red).
175193
final bool isDestructiveAction;
194+
195+
/// Change textStyle to another from default.
196+
///
197+
/// Recommended to keep null.
176198
final TextStyle textStyle;
177199
}
178200

201+
// Used to specify [showOkCancelAlertDialog]'s [defaultType]
179202
enum OkCancelAlertDefaultType {
180203
ok,
181204
cancel,
182205
}
206+
207+
// Result type of [showOkAlertDialog] or [showOkCancelAlertDialog].
183208
enum OkCancelResult {
184209
ok,
185210
cancel,

lib/src/extensions/string.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
extension StringEx on String {
2+
/// Capitalize first letter
23
String get capitalized => '${this[0].toUpperCase()}${substring(1)}';
34

5+
/// Change to lower case and capitalize first letter
6+
///
7+
/// Used for changing `CANCEL` to `Cancel` typically.
48
String get capitalizedForce => toLowerCase().capitalized;
59
}

lib/src/extensions/theme_data.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
33
extension ThemeDataEx on ThemeData {
44
// ignore: lines_longer_than_80_chars
55
// TODO(mono): Add platform == TargetPlatform.macOS when it is supported on stable
6+
/// Return true is the platform is suitable for Cupertino(iOS) style
67
bool get isCupertinoStyle =>
78
platform == TargetPlatform.iOS; // || platform == TargetPlatform.macOS;
89
}

lib/src/modal_action_sheet.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import 'package:flutter/material.dart';
44

55
import 'extensions/extensions.dart';
66

7+
/// Show modal action sheet, whose appearance is adaptive according to platform
8+
9+
/// The [isDismissible] parameter only works for material style and it specifies
10+
/// whether the bottom sheet will be dismissed when user taps on the scrim.
711
Future<T> showModalActionSheet<T>({
812
@required BuildContext context,
913
String title,
@@ -89,6 +93,7 @@ Future<T> showModalActionSheet<T>({
8993
);
9094
}
9195

96+
/// Used for specifying [showModalActionSheet]'s actions.
9297
@immutable
9398
class SheetAction<T> {
9499
const SheetAction({

0 commit comments

Comments
 (0)