-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalert.dart
55 lines (49 loc) · 1.38 KB
/
alert.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:platty/src/theme.dart';
import 'package:platty/src/widgets/platform.dart';
Future<T> showPlatformDialog<T>({
@required BuildContext context,
bool androidBarrierDismissible = true,
WidgetBuilder builder,
TargetPlatform renderPlatform,
}) {
final platform = renderPlatform ?? PTheme.of(context).data.platform;
if (platform == TargetPlatform.android) {
return showDialog(
context: context,
barrierDismissible: androidBarrierDismissible,
builder: builder);
} else {
return showCupertinoDialog(context: context, builder: builder);
}
}
class PAlertDialog extends PlatformAdaptingWidget {
final Widget title;
final Widget content;
final List<Widget> actions;
PAlertDialog(
{Key key,
this.title,
this.content,
@required this.actions,
TargetPlatform renderPlatform})
: super(key: key, renderPlatform: renderPlatform);
@override
get renderMaterial => (BuildContext context) {
return AlertDialog(
title: title,
content: content,
actions: actions,
);
};
@override
get renderCupertino => (BuildContext context) {
return CupertinoAlertDialog(
title: title,
content: content,
actions: actions,
);
};
}