Skip to content

Commit b8a9be4

Browse files
authored
Merge pull request #29 from go-flutter-desktop/revert-28-custom_error_codes
Revert "Custom error codes on the plugin side"
2 parents 08d5393 + a1db1e9 commit b8a9be4

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

plugin_tutorial/go-plugin-example/complex/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func (p *Example) InitPlugin(messenger plugin.BinaryMessenger) error {
2121

2222
p.channel = plugin.NewMethodChannel(messenger, "instance.id/go/data", plugin.StandardMethodCodec{})
2323
p.channel.HandleFunc("getData", getRemotesFunc)
24-
p.channel.HandleFunc("getError", getErrorFunc)
2524
p.channel.CatchAllHandleFunc(p.catchAllTest)
2625

2726
return nil
@@ -65,7 +64,3 @@ func getRemotesFunc(arguments interface{}) (reply interface{}, err error) {
6564

6665
return sectionList, nil
6766
}
68-
69-
func getErrorFunc(arguments interface{}) (reply interface{}, err error) {
70-
return nil, plugin.NewError("customErrorCode", errors.New("Some error"))
71-
}

plugin_tutorial/lib/main_desktop.dart

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,26 @@ void main() async {
2121
print(batteryLevel);
2222
});
2323

24-
group('Complex plugin', () {
24+
// A more complicated plugin
25+
//
26+
test('Test StandardMethodCodec array of map', () async {
2527
const platform_complex_structure =
2628
const MethodChannel('instance.id/go/data');
2729

28-
// A more complicated plugin
29-
test('Test StandardMethodCodec array of map', () async {
30-
final List<dynamic> result =
31-
await platform_complex_structure.invokeMethod('getData',
32-
"HelloFromDart"); // passing "HelloFromDart" as an argument
33-
expect(result, [
34-
{"instanceid": 1023, "pcbackup": "test", "brbackup": "test2"},
35-
{"instanceid": 1024, "pcbackup": "test", "brbackup": "test2"},
36-
{"instanceid": 1056, "pcbackup": "coucou", "brbackup": "coucou2"},
37-
{"instanceid": 3322, "pcbackup": "finaly", "brbackup": "finaly2"}
38-
]);
39-
40-
// golang can return the random methodName
41-
final String methodName =
42-
'test/' + new Random().nextInt(100000).toString();
43-
final String resultPathPrefix =
44-
await platform_complex_structure.invokeMethod(methodName);
45-
expect(resultPathPrefix, methodName);
46-
});
47-
48-
test('Custom errors', () async {
49-
var matcher = predicate(
50-
(e) => e is PlatformException && e.code == "customErrorCode");
51-
expect(
52-
platform_complex_structure.invokeMethod('getError'),
53-
throwsA(matcher),
54-
);
55-
});
30+
final List<dynamic> result = await platform_complex_structure.invokeMethod(
31+
'getData', "HelloFromDart"); // passing "HelloFromDart" as an argument
32+
expect(result, [
33+
{"instanceid": 1023, "pcbackup": "test", "brbackup": "test2"},
34+
{"instanceid": 1024, "pcbackup": "test", "brbackup": "test2"},
35+
{"instanceid": 1056, "pcbackup": "coucou", "brbackup": "coucou2"},
36+
{"instanceid": 3322, "pcbackup": "finaly", "brbackup": "finaly2"}
37+
]);
38+
39+
// golang can return the random methodName
40+
final String methodName = 'test/' + new Random().nextInt(100000).toString();
41+
final String resultPathPrefix =
42+
await platform_complex_structure.invokeMethod(methodName);
43+
expect(resultPathPrefix, methodName);
5644
});
5745

5846
tearDownAll(() async {

0 commit comments

Comments
 (0)