/
ai_amap_widget.dart
72 lines (64 loc) · 1.67 KB
/
ai_amap_widget.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import 'package:flutter/material.dart';
///
/// AiAMapPlatformWidget
// ignore: must_be_immutable
class AiAMapPlatformWidget extends StatefulWidget {
///
static const String UNSUPPORTED_DESCRIPTION_DEFAULT = "Unsupported platform";
String _unsupportedDescription;
///
/// constructor
AiAMapPlatformWidget({
String unsupportedDescription = UNSUPPORTED_DESCRIPTION_DEFAULT,
}) {
_unsupportedDescription =
unsupportedDescription ?? UNSUPPORTED_DESCRIPTION_DEFAULT;
}
@override
State<StatefulWidget> createState() {
return _AiAMapPlatformState(
unsupportedDescription: _unsupportedDescription);
}
}
///
/// _AiAMapPlatformState
class _AiAMapPlatformState extends State<AiAMapPlatformWidget> {
static const String _viewTypeId = "view_type_id_map_platform_view";
String _unsupportedDescription;
///
/// constructor
_AiAMapPlatformState({
@required String unsupportedDescription,
}) {
//values
_unsupportedDescription = unsupportedDescription;
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(child: _getPlatformView()),
],
);
}
Widget _getPlatformView() {
var platform = Theme.of(context).platform;
if (platform == TargetPlatform.android) {
return AndroidView(
viewType: _viewTypeId,
onPlatformViewCreated: (int id) {
//created callback
},
);
} else if (platform == TargetPlatform.iOS) {
return UiKitView(
viewType: _viewTypeId,
onPlatformViewCreated: (int id) {
//created callback
},
);
} else {
return Text(_unsupportedDescription);
}
}
}