mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.2 KiB
101 lines
3.2 KiB
5 years ago
|
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
|
||
|
// See also: https://pub.dev/packages/pigeon
|
||
|
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
|
||
|
import 'dart:async';
|
||
|
import 'package:flutter/services.dart';
|
||
|
|
||
|
class Book {
|
||
|
String title;
|
||
|
String subtitle;
|
||
|
String author;
|
||
|
String description;
|
||
|
String publishDate;
|
||
|
int pageCount;
|
||
|
// ignore: unused_element
|
||
|
Map<dynamic, dynamic> _toMap() {
|
||
|
final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{};
|
||
|
pigeonMap['title'] = title;
|
||
|
pigeonMap['subtitle'] = subtitle;
|
||
|
pigeonMap['author'] = author;
|
||
|
pigeonMap['description'] = description;
|
||
|
pigeonMap['publishDate'] = publishDate;
|
||
|
pigeonMap['pageCount'] = pageCount;
|
||
|
return pigeonMap;
|
||
|
}
|
||
|
|
||
|
// ignore: unused_element
|
||
|
static Book _fromMap(Map<dynamic, dynamic> pigeonMap) {
|
||
|
final Book result = Book();
|
||
|
result.title = pigeonMap['title'];
|
||
|
result.subtitle = pigeonMap['subtitle'];
|
||
|
result.author = pigeonMap['author'];
|
||
|
result.description = pigeonMap['description'];
|
||
|
result.publishDate = pigeonMap['publishDate'];
|
||
|
result.pageCount = pigeonMap['pageCount'];
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
abstract class FlutterBookApi {
|
||
|
void displayBookDetails(Book arg);
|
||
|
static void setup(FlutterBookApi api) {
|
||
|
{
|
||
|
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||
|
'dev.flutter.pigeon.FlutterBookApi.displayBookDetails',
|
||
|
StandardMessageCodec());
|
||
|
channel.setMessageHandler((dynamic message) async {
|
||
|
final Map<dynamic, dynamic> mapMessage =
|
||
|
message as Map<dynamic, dynamic>;
|
||
|
final Book input = Book._fromMap(mapMessage);
|
||
|
api.displayBookDetails(input);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class HostBookApi {
|
||
|
Future<void> cancel() async {
|
||
|
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||
|
'dev.flutter.pigeon.HostBookApi.cancel', StandardMessageCodec());
|
||
|
|
||
|
final Map<dynamic, dynamic> replyMap = await channel.send(null);
|
||
|
if (replyMap == null) {
|
||
|
throw PlatformException(
|
||
|
code: 'channel-error',
|
||
|
message: 'Unable to establish connection on channel.',
|
||
|
details: null);
|
||
|
} else if (replyMap['error'] != null) {
|
||
|
final Map<dynamic, dynamic> error = replyMap['error'];
|
||
|
throw PlatformException(
|
||
|
code: error['code'],
|
||
|
message: error['message'],
|
||
|
details: error['details']);
|
||
|
} else {
|
||
|
// noop
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Future<void> finishEditingBook(Book arg) async {
|
||
|
final Map<dynamic, dynamic> requestMap = arg._toMap();
|
||
|
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||
|
'dev.flutter.pigeon.HostBookApi.finishEditingBook',
|
||
|
StandardMessageCodec());
|
||
|
|
||
|
final Map<dynamic, dynamic> replyMap = await channel.send(requestMap);
|
||
|
if (replyMap == null) {
|
||
|
throw PlatformException(
|
||
|
code: 'channel-error',
|
||
|
message: 'Unable to establish connection on channel.',
|
||
|
details: null);
|
||
|
} else if (replyMap['error'] != null) {
|
||
|
final Map<dynamic, dynamic> error = replyMap['error'];
|
||
|
throw PlatformException(
|
||
|
code: error['code'],
|
||
|
message: error['message'],
|
||
|
details: error['details']);
|
||
|
} else {
|
||
|
// noop
|
||
|
}
|
||
|
}
|
||
|
}
|