Я хочу отправить данные объекта, как в примере Pusher 1.0.0 , данные для отправки находятся в форме папки и соответствуют моей кодировке:
import 'package:pusher/pusher.dart';
Future<void> mmain(Map data) async {
Pusher pu = new Pusher('PUSHER_APP_ID', 'PUSHER_APP_KEY',
'PUSHER_APP_SECRET', PusherOptions(cluster: 'ap1'));
// Map data = {'message': 'Hello world'};
Response res = await pu.trigger(['channelTa'], 'tombol', data);
print(res);
}
и я вызываю с помощью переключателя:
child: Switch(
value: widget.mdata[0]['m' + index.toString()],
onChanged: (value) {
setState(() {
widget.mdata[0]['m' + index.toString()] =value;
widget.mdata.asMap().forEach((index, value) {
String aja = "m$index";
tbl.update(aja, (value) => value);
});
mmain(tbl);
});
}),
что не так с моей кодировкой, поэтому отображается следующая ошибка:
Reload already in progress, ignoring request
Restarted application in 4.457ms.
D/PusherPlugin(15412): onCancel args: null
I/flutter (15412): CONNECTING
I/flutter (15412): CONNECTED
E/flutter (15412): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: Unexpected character (at character 2)
E/flutter (15412): {m0: false, m1: false, m2: false, m3: false, m4: false, m5: false}
E/flutter (15412): ^
E/flutter (15412):
[38;5;244mE/flutter (15412): #0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1394:5)[39;49m
[38;5;244mE/flutter (15412): #1 _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:924:48)[39;49m
[38;5;244mE/flutter (15412): #2 _parseJson (dart:convert-patch/convert_patch.dart:31:10)[39;49m
[38;5;244mE/flutter (15412): #3 JsonDecoder.convert (dart:convert/json.dart:505:36)[39;49m
[38;5;244mE/flutter (15412): #4 JsonCodec.decode (dart:convert/json.dart:153:41)[39;49m
[38;5;248mE/flutter (15412): #5 _MyHomePageState._konekpusher.<anonymous closure>[39;49m
[38;5;248mE/flutter (15412): #6 Pusher._handleEvent[39;49m
[38;5;244mE/flutter (15412): #7 _rootRunUnary (dart:async/zone.dart:1192:38)[39;49m
[38;5;244mE/flutter (15412): #8 _CustomZone.runUnary (dart:async/zone.dart:1085:19)[39;49m
[38;5;244mE/flutter (15412): #9 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)[39;49m
[38;5;244mE/flutter (15412): #10 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)[39;49m
[38;5;244mE/flutter (15412): #11 _DelayedData.perform (dart:async/stream_impl.dart:594:14)[39;49m
[38;5;244mE/flutter (15412): #12 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:710:11)[39;49m
[38;5;244mE/flutter (15412): #13 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:670:7)[39;49m
[38;5;244mE/flutter (15412): #14 _rootRun (dart:async/zone.dart:1180:38)[39;49m
[38;5;244mE/flutter (15412): #15 _CustomZone.run (dart:async/zone.dart:1077:19)[39;49m
[38;5;244mE/flutter (15412): #16 _CustomZone.runGuarded (dart:async/zone.dart:979:7)[39;49m
[38;5;244mE/flutter (15412): #17 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)[39;49m
[38;5;244mE/flutter (15412): #18 _rootRun (dart:async/zone.dart:1184:13)[39;49m
[38;5;244mE/flutter (15412): #19 _CustomZone.run (dart:async/zone.dart:1077:19)[39;49m
[38;5;244mE/flutter (15412): #20 _CustomZone.runGuarded (dart:async/zone.dart:979:7)[39;49m
[38;5;244mE/flutter (15412): #21 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)[39;49m
[38;5;244mE/flutter (15412): #22 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)[39;49m
[38;5;244mE/flutter (15412): #23 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)[39;49m
E/flutter (15412):
I/flutter (15412): {}
pusher возвращает только пустой json