Last updated:
0 purchases
flutter channel json
flutter_channel_json #
It is used to standardize the data format of method channel data transmission, usually combined with fluent_ channel_ event_ Bus use.
Add dependency #
flutter pub add flutter_channel_json
copied to clipboard
How do you use it? #
Dart #
import 'package:flutter_channel_json/flutter_channel_json.dart';
copied to clipboard
Default initialization
const json = FlutterChannelJson(
code: 300,
message: 'message',
success: false,
data: 2,
);
copied to clipboard
Initialize according to dictionary
final json = FlutterChannelJson.fromJson({
'code': 300,
'message': 'message',
'data': 2,
'success': false,
});
copied to clipboard
Initialization based on JSON string
final json = FlutterChannelJson.fromJsonString(
'{"code": 300, "message": "message", "data": 2, "success": false}',
);
copied to clipboard
Convert object to dictionary
final json = const FlutterChannelJson(
code: 300,
message: 'message',
success: false,
data: 2,
).toJson();
copied to clipboard
Convert object to string
final json = const FlutterChannelJson(
code: 300,
message: 'message',
success: false,
data: 2,
).toJsonString();
copied to clipboard
Initialization success type
final json = FlutterChannelJson.success(2);
copied to clipboard
Initialization failure type
final json = FlutterChannelJson.failure('message');
copied to clipboard
Swift #
Default initialization
let json = FlutterChannelJson(code: 300,
message: "message",
data: 2,
success: false)
copied to clipboard
Initialization success type
let json = FlutterChannelJson(success: 2)
copied to clipboard
Initialization failure type
let json = FlutterChannelJson(failure: "message", code: 300)
copied to clipboard
Initialize according to dictionary
let json = FlutterChannelJson<Int>(json: ["code": 300,
"message": "message",
"data": 2,
"success": false])
copied to clipboard
Initialization based on JSON string
let json = try? FlutterChannelJson<Int>(jsonString: "{\"code\":300,\"message\":\"message\",\"data\":2,\"success\":false}")
copied to clipboard
Object to JSON string
let json = FlutterChannelJson(code: 300,
message: "message",
data: 2,
success: false)
let jsonString = json.toJsonString()
copied to clipboard
Object to dictionary
let json = FlutterChannelJson(code: 300,
message: "message",
data: 2,
success: false)
let jsonMap = json.toJson()
copied to clipboard
Kotlin #
Default initialization
val json = FlutterChannelJson(code = 300, message = "message", data = 2, success = false)
copied to clipboard
Initialization success type
val json = FlutterChannelJson(data = 2)
copied to clipboard
Initialization failure type
val json = FlutterChannelJson<Int>(message = "message")
copied to clipboard
Initialization based on JSON string
val json = FlutterChannelJson(jsonString = "{\"code\":300,\"message\":\"message\",\"data\":2,\"success\":false}", Int::class.java)
copied to clipboard
Initialize according to dictionary
val map: Map<String,Any> = mapOf("code" to 300, "message" to "message", "data" to 2, "success" to false)
val json = FlutterChannelJson<Int>(json = map)
copied to clipboard
Object to JSON string
val json = FlutterChannelJson(code = 300, message = "message", data = 2, success = false).toJsonString()
copied to clipboard
Object to dictionary
val json = FlutterChannelJson(code = 300, message = "message", data = 2, success = false)
val map = json.toJson()
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.