updated add_to_app sample to pigeon 1.0 (#894)

pull/895/head
gaaclarke 3 years ago committed by GitHub
parent 69abb6146a
commit e43698fa01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,16 +1,23 @@
// Autogenerated from Pigeon (v0.1.17), do not edit directly. // Autogenerated from Pigeon (v1.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
package dev.flutter.example.books; package dev.flutter.example.books;
import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MessageCodec;
import io.flutter.plugin.common.StandardMessageCodec; import io.flutter.plugin.common.StandardMessageCodec;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** Generated class from Pigeon. */ /** Generated class from Pigeon. */
@SuppressWarnings("unused") @SuppressWarnings(
{"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})
public class Api { public class Api {
/** Generated class from Pigeon that represents data sent in messages. */ /** Generated class from Pigeon that represents data sent in messages. */
@ -33,23 +40,33 @@ public class Api {
private String publishDate; private String publishDate;
public String getPublishDate() { return publishDate; } public String getPublishDate() { return publishDate; }
public void setPublishDate(String setterArg) { this.publishDate = setterArg; } public void setPublishDate(String setterArg) {
this.publishDate = setterArg;
}
private Long pageCount; private Long pageCount;
public Long getPageCount() { return pageCount; } public Long getPageCount() { return pageCount; }
public void setPageCount(Long setterArg) { this.pageCount = setterArg; } public void setPageCount(Long setterArg) { this.pageCount = setterArg; }
HashMap toMap() { private Thumbnail thumbnail;
HashMap<String, Object> toMapResult = new HashMap<>(); public Thumbnail getThumbnail() { return thumbnail; }
public void setThumbnail(Thumbnail setterArg) {
this.thumbnail = setterArg;
}
Map<String, Object> toMap() {
Map<String, Object> toMapResult = new HashMap<>();
toMapResult.put("title", title); toMapResult.put("title", title);
toMapResult.put("subtitle", subtitle); toMapResult.put("subtitle", subtitle);
toMapResult.put("author", author); toMapResult.put("author", author);
toMapResult.put("summary", summary); toMapResult.put("summary", summary);
toMapResult.put("publishDate", publishDate); toMapResult.put("publishDate", publishDate);
toMapResult.put("pageCount", pageCount); toMapResult.put("pageCount", pageCount);
toMapResult.put("thumbnail",
(thumbnail == null) ? null : thumbnail.toMap());
return toMapResult; return toMapResult;
} }
static Book fromMap(HashMap map) { static Book fromMap(Map<String, Object> map) {
Book fromMapResult = new Book(); Book fromMapResult = new Book();
Object title = map.get("title"); Object title = map.get("title");
fromMapResult.title = (String)title; fromMapResult.title = (String)title;
@ -62,48 +79,135 @@ public class Api {
Object publishDate = map.get("publishDate"); Object publishDate = map.get("publishDate");
fromMapResult.publishDate = (String)publishDate; fromMapResult.publishDate = (String)publishDate;
Object pageCount = map.get("pageCount"); Object pageCount = map.get("pageCount");
fromMapResult.pageCount = (pageCount == null) ? null : ((pageCount instanceof Integer) ? (Integer)pageCount : (Long)pageCount); fromMapResult.pageCount =
(pageCount == null)
? null
: ((pageCount instanceof Integer) ? (Integer)pageCount
: (Long)pageCount);
Object thumbnail = map.get("thumbnail");
fromMapResult.thumbnail = Thumbnail.fromMap((Map)thumbnail);
return fromMapResult;
}
}
/** Generated class from Pigeon that represents data sent in messages. */
public static class Thumbnail {
private String url;
public String getUrl() { return url; }
public void setUrl(String setterArg) { this.url = setterArg; }
Map<String, Object> toMap() {
Map<String, Object> toMapResult = new HashMap<>();
toMapResult.put("url", url);
return toMapResult;
}
static Thumbnail fromMap(Map<String, Object> map) {
Thumbnail fromMapResult = new Thumbnail();
Object url = map.get("url");
fromMapResult.url = (String)url;
return fromMapResult; return fromMapResult;
} }
} }
private static class FlutterBookApiCodec extends StandardMessageCodec {
public static final FlutterBookApiCodec INSTANCE =
new FlutterBookApiCodec();
private FlutterBookApiCodec() {}
@Override
protected Object readValueOfType(byte type, ByteBuffer buffer) {
switch (type) {
case (byte)128:
return Book.fromMap((Map<String, Object>)readValue(buffer));
default:
return super.readValueOfType(type, buffer);
}
}
@Override
protected void writeValue(ByteArrayOutputStream stream, Object value) {
if (value instanceof Book) {
stream.write(128);
writeValue(stream, ((Book)value).toMap());
} else {
super.writeValue(stream, value);
}
}
}
/** Generated class from Pigeon that represents Flutter messages that can be called from Java.*/ /**
* Generated class from Pigeon that represents Flutter messages that can be
* called from Java.
*/
public static class FlutterBookApi { public static class FlutterBookApi {
private final BinaryMessenger binaryMessenger; private final BinaryMessenger binaryMessenger;
public FlutterBookApi(BinaryMessenger argBinaryMessenger){ public FlutterBookApi(BinaryMessenger argBinaryMessenger) {
this.binaryMessenger = argBinaryMessenger; this.binaryMessenger = argBinaryMessenger;
} }
public interface Reply<T> { public interface Reply<T> {
void reply(T reply); void reply(T reply);
} }
public void displayBookDetails(Book argInput, Reply<Void> callback) { static MessageCodec<Object> getCodec() {
BasicMessageChannel<Object> channel = return FlutterBookApiCodec.INSTANCE;
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.FlutterBookApi.displayBookDetails", new StandardMessageCodec()); }
HashMap inputMap = argInput.toMap();
channel.send(inputMap, channelReply -> { public void displayBookDetails(Book bookArg, Reply<Void> callback) {
callback.reply(null); BasicMessageChannel<Object> channel = new BasicMessageChannel<>(
}); binaryMessenger,
"dev.flutter.pigeon.FlutterBookApi.displayBookDetails", getCodec());
channel.send(new ArrayList<Object>(Arrays.asList(bookArg)),
channelReply -> { callback.reply(null); });
}
}
private static class HostBookApiCodec extends StandardMessageCodec {
public static final HostBookApiCodec INSTANCE = new HostBookApiCodec();
private HostBookApiCodec() {}
@Override
protected Object readValueOfType(byte type, ByteBuffer buffer) {
switch (type) {
case (byte)128:
return Book.fromMap((Map<String, Object>)readValue(buffer));
default:
return super.readValueOfType(type, buffer);
}
}
@Override
protected void writeValue(ByteArrayOutputStream stream, Object value) {
if (value instanceof Book) {
stream.write(128);
writeValue(stream, ((Book)value).toMap());
} else {
super.writeValue(stream, value);
}
} }
} }
/** Generated interface from Pigeon that represents a handler of messages from Flutter.*/ /**
* Generated interface from Pigeon that represents a handler of messages from
* Flutter.
*/
public interface HostBookApi { public interface HostBookApi {
void cancel(); void cancel();
void finishEditingBook(Book arg); void finishEditingBook(Book book);
/** Sets up an instance of `HostBookApi` to handle messages through the `binaryMessenger` */ /** The codec used by HostBookApi. */
static MessageCodec<Object> getCodec() { return HostBookApiCodec.INSTANCE; }
/**
* Sets up an instance of `HostBookApi` to handle messages through the
* `binaryMessenger`.
*/
static void setup(BinaryMessenger binaryMessenger, HostBookApi api) { static void setup(BinaryMessenger binaryMessenger, HostBookApi api) {
{ {
BasicMessageChannel<Object> channel = BasicMessageChannel<Object> channel = new BasicMessageChannel<>(
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.HostBookApi.cancel", new StandardMessageCodec()); binaryMessenger, "dev.flutter.pigeon.HostBookApi.cancel",
getCodec());
if (api != null) { if (api != null) {
channel.setMessageHandler((message, reply) -> { channel.setMessageHandler((message, reply) -> {
HashMap<String, HashMap> wrapped = new HashMap<>(); Map<String, Object> wrapped = new HashMap<>();
try { try {
api.cancel(); api.cancel();
wrapped.put("result", null); wrapped.put("result", null);
} } catch (Error | RuntimeException exception) {
catch (Exception exception) {
wrapped.put("error", wrapError(exception)); wrapped.put("error", wrapError(exception));
} }
reply.reply(wrapped); reply.reply(wrapped);
@ -113,18 +217,21 @@ public class Api {
} }
} }
{ {
BasicMessageChannel<Object> channel = BasicMessageChannel<Object> channel = new BasicMessageChannel<>(
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.HostBookApi.finishEditingBook", new StandardMessageCodec()); binaryMessenger, "dev.flutter.pigeon.HostBookApi.finishEditingBook",
getCodec());
if (api != null) { if (api != null) {
channel.setMessageHandler((message, reply) -> { channel.setMessageHandler((message, reply) -> {
HashMap<String, HashMap> wrapped = new HashMap<>(); Map<String, Object> wrapped = new HashMap<>();
try { try {
@SuppressWarnings("ConstantConditions") ArrayList<Object> args = (ArrayList<Object>)message;
Book input = Book.fromMap((HashMap)message); Book bookArg = (Book)args.get(0);
api.finishEditingBook(input); if (bookArg == null) {
throw new NullPointerException("bookArg unexpectedly null.");
}
api.finishEditingBook(bookArg);
wrapped.put("result", null); wrapped.put("result", null);
} } catch (Error | RuntimeException exception) {
catch (Exception exception) {
wrapped.put("error", wrapError(exception)); wrapped.put("error", wrapError(exception));
} }
reply.reply(wrapped); reply.reply(wrapped);
@ -135,8 +242,8 @@ public class Api {
} }
} }
} }
private static HashMap wrapError(Exception exception) { private static Map<String, Object> wrapError(Throwable exception) {
HashMap<String, Object> errorMap = new HashMap<>(); Map<String, Object> errorMap = new HashMap<>();
errorMap.put("message", exception.toString()); errorMap.put("message", exception.toString());
errorMap.put("code", exception.getClass().getSimpleName()); errorMap.put("code", exception.getClass().getSimpleName());
errorMap.put("details", null); errorMap.put("details", null);

@ -43,7 +43,7 @@ class FlutterBookActivity: FlutterActivity() {
// TODO(gaaclarke): the Pigeon generated data class should just implement // TODO(gaaclarke): the Pigeon generated data class should just implement
// Serializable so we won't need 'toMap()' here // Serializable so we won't need 'toMap()' here
// https://github.com/flutter/flutter/issues/58909 // https://github.com/flutter/flutter/issues/58909
book.toMap() HashMap(book.toMap())
) )
} }
@ -54,7 +54,7 @@ class FlutterBookActivity: FlutterActivity() {
* activity's {@code onActivityResult}. * activity's {@code onActivityResult}.
*/ */
fun getBookFromResultIntent(resultIntent: Intent): Api.Book { fun getBookFromResultIntent(resultIntent: Intent): Api.Book {
return Api.Book.fromMap(resultIntent.getSerializableExtra(FlutterBookActivity.EXTRA_BOOK) as HashMap<*, *>); return Api.Book.fromMap((resultIntent.getSerializableExtra(FlutterBookActivity.EXTRA_BOOK) as HashMap<String, Any>));
} }
} }
@ -68,7 +68,7 @@ class FlutterBookActivity: FlutterActivity() {
// The book to give to Flutter is passed in from the MainActivity via this activity's // The book to give to Flutter is passed in from the MainActivity via this activity's
// source intent getter. The intent contains the book serialized as on extra. // source intent getter. The intent contains the book serialized as on extra.
val bookToShow = Api.Book.fromMap(intent.getSerializableExtra(EXTRA_BOOK) as HashMap<*, *>) val bookToShow = Api.Book.fromMap(intent.getSerializableExtra(EXTRA_BOOK) as HashMap<String, Any>)
// Register the HostBookApiHandler callback class to get results from Flutter. // Register the HostBookApiHandler callback class to get results from Flutter.
Api.HostBookApi.setup(flutterEngine.dartExecutor, HostBookApiHandler()) Api.HostBookApi.setup(flutterEngine.dartExecutor, HostBookApiHandler())
@ -94,7 +94,7 @@ class FlutterBookActivity: FlutterActivity() {
} }
// Flutter returned an edited book instance. Return it to the MainActivity via the // Flutter returned an edited book instance. Return it to the MainActivity via the
// standard Android Activity set result mechanism. // standard Android Activity set result mechanism.
setResult(Activity.RESULT_OK, Intent().putExtra(EXTRA_BOOK, book.toMap())) setResult(Activity.RESULT_OK, Intent().putExtra(EXTRA_BOOK, HashMap(book.toMap())))
finish() finish()
} }
} }

@ -1,61 +1,107 @@
// Autogenerated from Pigeon (v0.1.17), do not edit directly. // Autogenerated from Pigeon (v1.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name
// @dart = 2.8 // @dart = 2.12
import 'dart:async'; import 'dart:async';
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
class Book { class Book {
String title; String? title;
String subtitle; String? subtitle;
String author; String? author;
String summary; String? summary;
String publishDate; String? publishDate;
int pageCount; int? pageCount;
Thumbnail? thumbnail;
// ignore: unused_element
Object encode() { Object encode() {
final Map<Object, Object> pigeonMap = <Object, Object>{}; final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
pigeonMap['title'] = title; pigeonMap['title'] = title;
pigeonMap['subtitle'] = subtitle; pigeonMap['subtitle'] = subtitle;
pigeonMap['author'] = author; pigeonMap['author'] = author;
pigeonMap['summary'] = summary; pigeonMap['summary'] = summary;
pigeonMap['publishDate'] = publishDate; pigeonMap['publishDate'] = publishDate;
pigeonMap['pageCount'] = pageCount; pigeonMap['pageCount'] = pageCount;
pigeonMap['thumbnail'] = thumbnail == null ? null : thumbnail!.encode();
return pigeonMap; return pigeonMap;
} }
// ignore: unused_element
static Book decode(Object message) { static Book decode(Object message) {
final Map<Object, Object> pigeonMap = message as Map<Object, Object>; final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
return Book() return Book()
..title = pigeonMap['title'] as String ..title = pigeonMap['title'] as String?
..subtitle = pigeonMap['subtitle'] as String ..subtitle = pigeonMap['subtitle'] as String?
..author = pigeonMap['author'] as String ..author = pigeonMap['author'] as String?
..summary = pigeonMap['summary'] as String ..summary = pigeonMap['summary'] as String?
..publishDate = pigeonMap['publishDate'] as String ..publishDate = pigeonMap['publishDate'] as String?
..pageCount = pigeonMap['pageCount'] as int; ..pageCount = pigeonMap['pageCount'] as int?
..thumbnail = pigeonMap['thumbnail'] != null
? Thumbnail.decode(pigeonMap['thumbnail']!)
: null;
}
}
class Thumbnail {
String? url;
Object encode() {
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
pigeonMap['url'] = url;
return pigeonMap;
}
static Thumbnail decode(Object message) {
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
return Thumbnail()..url = pigeonMap['url'] as String?;
}
}
class _FlutterBookApiCodec extends StandardMessageCodec {
const _FlutterBookApiCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is Book) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return Book.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
}
} }
} }
abstract class FlutterBookApi { abstract class FlutterBookApi {
static const MessageCodec<Object?> codec = _FlutterBookApiCodec();
void displayBookDetails(Book book); void displayBookDetails(Book book);
static void setup(FlutterBookApi api) { static void setup(FlutterBookApi? api) {
{ {
const BasicMessageChannel<Object> channel = BasicMessageChannel<Object>( const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FlutterBookApi.displayBookDetails', 'dev.flutter.pigeon.FlutterBookApi.displayBookDetails', codec);
StandardMessageCodec());
if (api == null) { if (api == null) {
channel.setMessageHandler(null); channel.setMessageHandler(null);
} else { } else {
channel.setMessageHandler((message) async { channel.setMessageHandler((Object? message) async {
if (message == null) { assert(message != null,
return; 'Argument for dev.flutter.pigeon.FlutterBookApi.displayBookDetails was null.');
} final List<Object?> args = (message as List<Object?>?)!;
final Book input = Book.decode(message); final Book? arg_book = args[0] as Book?;
api.displayBookDetails(input); assert(arg_book != null,
'Argument for dev.flutter.pigeon.FlutterBookApi.displayBookDetails was null, expected non-null Book.');
api.displayBookDetails(arg_book!);
return; return;
}); });
} }
@ -63,12 +109,47 @@ abstract class FlutterBookApi {
} }
} }
class _HostBookApiCodec extends StandardMessageCodec {
const _HostBookApiCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is Book) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return Book.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
}
}
}
class HostBookApi { class HostBookApi {
/// Constructor for [HostBookApi]. The [binaryMessenger] named argument is
/// available for dependency injection. If it is left null, the default
/// BinaryMessenger will be used which routes to the host platform.
HostBookApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
final BinaryMessenger? _binaryMessenger;
static const MessageCodec<Object?> codec = _HostBookApiCodec();
Future<void> cancel() async { Future<void> cancel() async {
const BasicMessageChannel<Object> channel = BasicMessageChannel<Object>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.HostBookApi.cancel', StandardMessageCodec()); 'dev.flutter.pigeon.HostBookApi.cancel', codec,
final Map<Object, Object> replyMap = binaryMessenger: _binaryMessenger);
await channel.send(null) as Map<Object, Object>; final Map<Object?, Object?>? replyMap =
await channel.send(null) as Map<Object?, Object?>?;
if (replyMap == null) { if (replyMap == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -76,25 +157,24 @@ class HostBookApi {
details: null, details: null,
); );
} else if (replyMap['error'] != null) { } else if (replyMap['error'] != null) {
final Map<Object, Object> error = final Map<Object?, Object?> error =
replyMap['error'] as Map<Object, Object>; (replyMap['error'] as Map<Object?, Object?>?)!;
throw PlatformException( throw PlatformException(
code: error['code'] as String, code: (error['code'] as String?)!,
message: error['message'] as String, message: error['message'] as String?,
details: error['details'], details: error['details'],
); );
} else { } else {
// noop return;
} }
} }
Future<void> finishEditingBook(Book arg) async { Future<void> finishEditingBook(Book arg_book) async {
final Object encoded = arg.encode(); final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
const BasicMessageChannel<Object> channel = BasicMessageChannel<Object>( 'dev.flutter.pigeon.HostBookApi.finishEditingBook', codec,
'dev.flutter.pigeon.HostBookApi.finishEditingBook', binaryMessenger: _binaryMessenger);
StandardMessageCodec()); final Map<Object?, Object?>? replyMap =
final Map<Object, Object> replyMap = await channel.send(<Object>[arg_book]) as Map<Object?, Object?>?;
await channel.send(encoded) as Map<Object, Object>;
if (replyMap == null) { if (replyMap == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -102,15 +182,15 @@ class HostBookApi {
details: null, details: null,
); );
} else if (replyMap['error'] != null) { } else if (replyMap['error'] != null) {
final Map<Object, Object> error = final Map<Object?, Object?> error =
replyMap['error'] as Map<Object, Object>; (replyMap['error'] as Map<Object?, Object?>?)!;
throw PlatformException( throw PlatformException(
code: error['code'] as String, code: (error['code'] as String?)!,
message: error['message'] as String, message: error['message'] as String?,
details: error['details'], details: error['details'],
); );
} else { } else {
// noop return;
} }
} }
} }

@ -11,14 +11,12 @@ class Book {
String summary; String summary;
String publishDate; String publishDate;
int pageCount; int pageCount;
// Thumbnail thumbnail; Thumbnail thumbnail;
} }
// TODO(gaaclarke): add this back when the https://github.com/flutter/flutter/issues/58896 class Thumbnail {
// crash is resolved. String url;
// class Thumbnail { }
// String url;
// }
@FlutterApi() @FlutterApi()
abstract class FlutterBookApi { abstract class FlutterBookApi {

@ -1,20 +1,34 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "22.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.2"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.0" version: "2.2.0"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.6.1" version: "2.8.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -22,6 +36,27 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.1"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.2"
characters: characters:
dependency: transitive dependency: transitive
description: description:
@ -35,7 +70,14 @@ packages:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.1"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -43,6 +85,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -50,6 +99,27 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -57,6 +127,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -74,6 +158,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -81,27 +172,41 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.1"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10" version: "0.12.11"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.7.0"
mockito: mockito:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: mockito name: mockito
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.1+1" version: "5.0.15"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -109,18 +214,39 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
pigeon: pigeon:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: pigeon name: pigeon
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.23" version: "1.0.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.99" version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -162,7 +288,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.4.3"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -177,5 +303,19 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.12.0 <3.0.0"

@ -13,8 +13,8 @@ dependencies:
sdk: flutter sdk: flutter
dev_dependencies: dev_dependencies:
pigeon: ^0.1.0 pigeon: ^1.0.0
mockito: ^4.1.1 mockito: ^5.0.0
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^1.0.0 flutter_lints: ^1.0.0

@ -103,7 +103,7 @@ class ViewController: UITableViewController, BKHostBookApi {
let flutterViewController = FlutterViewController.init( let flutterViewController = FlutterViewController.init(
engine: appDelegate.engine, nibName: nil, bundle: nil) engine: appDelegate.engine, nibName: nil, bundle: nil)
self.editingIndex = index self.editingIndex = index
api.displayBookDetails(self.books[index]) { (error) in api.displayBookDetailsBook(self.books[index]) { (error) in
if let error = error { if let error = error {
print(error) print(error)
} }
@ -114,7 +114,7 @@ class ViewController: UITableViewController, BKHostBookApi {
/** /**
Called by Pigeon when the FlutterViewController is dismissed without accepting any edits. Called by Pigeon when the FlutterViewController is dismissed without accepting any edits.
*/ */
func cancel(_ error: AutoreleasingUnsafeMutablePointer<FlutterError?>) { func cancelWithError(_ error: AutoreleasingUnsafeMutablePointer<FlutterError?>) {
self.editingIndex = -1 self.editingIndex = -1
self.dismiss(animated: true, completion: nil) self.dismiss(animated: true, completion: nil)
} }
@ -122,7 +122,7 @@ class ViewController: UITableViewController, BKHostBookApi {
/** /**
Called by Pigeon when edits to the book are accepted in the FlutterViewController. Called by Pigeon when edits to the book are accepted in the FlutterViewController.
*/ */
func finishEditing(_ input: BKBook, error: AutoreleasingUnsafeMutablePointer<FlutterError?>) { func finishEditingBook(_ input: BKBook, error: AutoreleasingUnsafeMutablePointer<FlutterError?>) {
self.books[editingIndex] = input self.books[editingIndex] = input
self.tableView.reloadData() self.tableView.reloadData()
self.editingIndex = -1 self.editingIndex = -1

@ -1,32 +1,49 @@
// Autogenerated from Pigeon (v0.1.17), do not edit directly. // Autogenerated from Pigeon (v1.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@protocol FlutterBinaryMessenger; @protocol FlutterBinaryMessenger;
@protocol FlutterMessageCodec;
@class FlutterError; @class FlutterError;
@class FlutterStandardTypedData; @class FlutterStandardTypedData;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class BKBook; @class BKBook;
@class BKThumbnail;
@interface BKBook : NSObject @interface BKBook : NSObject
@property(nonatomic, copy, nullable) NSString * title; @property(nonatomic, copy, nullable) NSString *title;
@property(nonatomic, copy, nullable) NSString * subtitle; @property(nonatomic, copy, nullable) NSString *subtitle;
@property(nonatomic, copy, nullable) NSString * author; @property(nonatomic, copy, nullable) NSString *author;
@property(nonatomic, copy, nullable) NSString * summary; @property(nonatomic, copy, nullable) NSString *summary;
@property(nonatomic, copy, nullable) NSString * publishDate; @property(nonatomic, copy, nullable) NSString *publishDate;
@property(nonatomic, strong, nullable) NSNumber * pageCount; @property(nonatomic, strong, nullable) NSNumber *pageCount;
@property(nonatomic, strong, nullable) BKThumbnail *thumbnail;
@end @end
@interface BKThumbnail : NSObject
@property(nonatomic, copy, nullable) NSString *url;
@end
/// The codec used by BKFlutterBookApi.
NSObject<FlutterMessageCodec> *BKFlutterBookApiGetCodec(void);
@interface BKFlutterBookApi : NSObject @interface BKFlutterBookApi : NSObject
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger; - (instancetype)initWithBinaryMessenger:
- (void)displayBookDetails:(BKBook*)input completion:(void(^)(NSError* _Nullable))completion; (id<FlutterBinaryMessenger>)binaryMessenger;
- (void)displayBookDetailsBook:(BKBook *)book
completion:(void (^)(NSError *_Nullable))completion;
@end @end
/// The codec used by BKHostBookApi.
NSObject<FlutterMessageCodec> *BKHostBookApiGetCodec(void);
@protocol BKHostBookApi @protocol BKHostBookApi
-(void)cancel:(FlutterError *_Nullable *_Nonnull)error; - (void)cancelWithError:(FlutterError *_Nullable *_Nonnull)error;
-(void)finishEditingBook:(BKBook*)input error:(FlutterError *_Nullable *_Nonnull)error; - (void)finishEditingBookBook:(BKBook *)book
error:(FlutterError *_Nullable *_Nonnull)error;
@end @end
extern void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<BKHostBookApi> _Nullable api); extern void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<BKHostBookApi> *_Nullable api);
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.17), do not edit directly. // Autogenerated from Pigeon (v1.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
#import "api.h" #import "api.h"
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
@ -7,29 +7,34 @@
#error File requires ARC to be enabled. #error File requires ARC to be enabled.
#endif #endif
static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) { static NSDictionary<NSString *, id> *wrapResult(id result,
FlutterError *error) {
NSDictionary *errorDict = (NSDictionary *)[NSNull null]; NSDictionary *errorDict = (NSDictionary *)[NSNull null];
if (error) { if (error) {
errorDict = [NSDictionary dictionaryWithObjectsAndKeys: errorDict = @{
(error.code ? error.code : [NSNull null]), @"code", @"code" : (error.code ? error.code : [NSNull null]),
(error.message ? error.message : [NSNull null]), @"message", @"message" : (error.message ? error.message : [NSNull null]),
(error.details ? error.details : [NSNull null]), @"details", @"details" : (error.details ? error.details : [NSNull null]),
nil]; };
} }
return [NSDictionary dictionaryWithObjectsAndKeys: return @{
(result ? result : [NSNull null]), @"result", @"result" : (result ? result : [NSNull null]),
errorDict, @"error", @"error" : errorDict,
nil]; };
} }
@interface BKBook () @interface BKBook ()
+(BKBook*)fromMap:(NSDictionary*)dict; + (BKBook *)fromMap:(NSDictionary *)dict;
-(NSDictionary*)toMap; - (NSDictionary *)toMap;
@end
@interface BKThumbnail ()
+ (BKThumbnail *)fromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end @end
@implementation BKBook @implementation BKBook
+(BKBook*)fromMap:(NSDictionary*)dict { + (BKBook *)fromMap:(NSDictionary *)dict {
BKBook* result = [[BKBook alloc] init]; BKBook *result = [[BKBook alloc] init];
result.title = dict[@"title"]; result.title = dict[@"title"];
if ((NSNull *)result.title == [NSNull null]) { if ((NSNull *)result.title == [NSNull null]) {
result.title = nil; result.title = nil;
@ -54,68 +59,210 @@ static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) {
if ((NSNull *)result.pageCount == [NSNull null]) { if ((NSNull *)result.pageCount == [NSNull null]) {
result.pageCount = nil; result.pageCount = nil;
} }
result.thumbnail = [BKThumbnail fromMap:dict[@"thumbnail"]];
if ((NSNull *)result.thumbnail == [NSNull null]) {
result.thumbnail = nil;
}
return result;
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:
(self.title ? self.title : [NSNull null]), @"title",
(self.subtitle ? self.subtitle : [NSNull null]), @"subtitle",
(self.author ? self.author : [NSNull null]), @"author",
(self.summary ? self.summary : [NSNull null]), @"summary",
(self.publishDate ? self.publishDate : [NSNull null]), @"publishDate",
(self.pageCount ? self.pageCount : [NSNull null]), @"pageCount",
(self.thumbnail ? [self.thumbnail toMap] : [NSNull null]),
@"thumbnail", nil];
}
@end
@implementation BKThumbnail
+ (BKThumbnail *)fromMap:(NSDictionary *)dict {
BKThumbnail *result = [[BKThumbnail alloc] init];
result.url = dict[@"url"];
if ((NSNull *)result.url == [NSNull null]) {
result.url = nil;
}
return result; return result;
} }
-(NSDictionary*)toMap { - (NSDictionary *)toMap {
return [NSDictionary dictionaryWithObjectsAndKeys:(self.title ? self.title : [NSNull null]), @"title", (self.subtitle ? self.subtitle : [NSNull null]), @"subtitle", (self.author ? self.author : [NSNull null]), @"author", (self.summary ? self.summary : [NSNull null]), @"summary", (self.publishDate ? self.publishDate : [NSNull null]), @"publishDate", (self.pageCount ? self.pageCount : [NSNull null]), @"pageCount", nil]; return [NSDictionary
dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]),
@"url", nil];
}
@end
@interface BKFlutterBookApiCodecReader : FlutterStandardReader
@end
@implementation BKFlutterBookApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [BKBook fromMap:[self readValue]];
default:
return [super readValueOfType:type];
}
}
@end
@interface BKFlutterBookApiCodecWriter : FlutterStandardWriter
@end
@implementation BKFlutterBookApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[BKBook class]]) {
[self writeByte:128];
[self writeValue:[value toMap]];
} else {
[super writeValue:value];
}
}
@end
@interface BKFlutterBookApiCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation BKFlutterBookApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[BKFlutterBookApiCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[BKFlutterBookApiCodecReader alloc] initWithData:data];
} }
@end @end
NSObject<FlutterMessageCodec> *BKFlutterBookApiGetCodec() {
static dispatch_once_t s_pred = 0;
static FlutterStandardMessageCodec *s_sharedObject = nil;
dispatch_once(&s_pred, ^{
BKFlutterBookApiCodecReaderWriter *readerWriter =
[[BKFlutterBookApiCodecReaderWriter alloc] init];
s_sharedObject =
[FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return s_sharedObject;
}
@interface BKFlutterBookApi () @interface BKFlutterBookApi ()
@property (nonatomic, strong) NSObject<FlutterBinaryMessenger>* binaryMessenger; @property(nonatomic, strong) NSObject<FlutterBinaryMessenger> *binaryMessenger;
@end @end
@implementation BKFlutterBookApi @implementation BKFlutterBookApi
- (instancetype)initWithBinaryMessenger:(NSObject<FlutterBinaryMessenger>*)binaryMessenger { - (instancetype)initWithBinaryMessenger:
(NSObject<FlutterBinaryMessenger> *)binaryMessenger {
self = [super init]; self = [super init];
if (self) { if (self) {
self.binaryMessenger = binaryMessenger; _binaryMessenger = binaryMessenger;
} }
return self; return self;
} }
- (void)displayBookDetails:(BKBook*)input completion:(void(^)(NSError* _Nullable))completion { - (void)displayBookDetailsBook:(BKBook *)arg_book
FlutterBasicMessageChannel *channel = completion:(void (^)(NSError *_Nullable))completion {
[FlutterBasicMessageChannel FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
messageChannelWithName:@"dev.flutter.pigeon.FlutterBookApi.displayBookDetails" messageChannelWithName:
binaryMessenger:self.binaryMessenger]; @"dev.flutter.pigeon.FlutterBookApi.displayBookDetails"
NSDictionary* inputMap = [input toMap]; binaryMessenger:self.binaryMessenger
[channel sendMessage:inputMap reply:^(id reply) { codec:BKFlutterBookApiGetCodec()];
completion(nil); [channel sendMessage:@[ arg_book ]
}]; reply:^(id reply) {
completion(nil);
}];
}
@end
@interface BKHostBookApiCodecReader : FlutterStandardReader
@end
@implementation BKHostBookApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [BKBook fromMap:[self readValue]];
default:
return [super readValueOfType:type];
}
} }
@end @end
void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<BKHostBookApi> api) {
@interface BKHostBookApiCodecWriter : FlutterStandardWriter
@end
@implementation BKHostBookApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[BKBook class]]) {
[self writeByte:128];
[self writeValue:[value toMap]];
} else {
[super writeValue:value];
}
}
@end
@interface BKHostBookApiCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation BKHostBookApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[BKHostBookApiCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[BKHostBookApiCodecReader alloc] initWithData:data];
}
@end
NSObject<FlutterMessageCodec> *BKHostBookApiGetCodec() {
static dispatch_once_t s_pred = 0;
static FlutterStandardMessageCodec *s_sharedObject = nil;
dispatch_once(&s_pred, ^{
BKHostBookApiCodecReaderWriter *readerWriter =
[[BKHostBookApiCodecReaderWriter alloc] init];
s_sharedObject =
[FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return s_sharedObject;
}
void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<BKHostBookApi> *api) {
{ {
FlutterBasicMessageChannel *channel = FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
[FlutterBasicMessageChannel
messageChannelWithName:@"dev.flutter.pigeon.HostBookApi.cancel" messageChannelWithName:@"dev.flutter.pigeon.HostBookApi.cancel"
binaryMessenger:binaryMessenger]; binaryMessenger:binaryMessenger
codec:BKHostBookApiGetCodec()];
if (api) { if (api) {
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSCAssert(
FlutterError *error; [api respondsToSelector:@selector(cancelWithError:)],
[api cancel:&error]; @"BKHostBookApi api doesn't respond to @selector(cancelWithError:)");
callback(wrapResult(nil, error)); [channel
}]; setMessageHandler:^(id _Nullable message, FlutterReply callback) {
} FlutterError *error;
else { [api cancelWithError:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil]; [channel setMessageHandler:nil];
} }
} }
{ {
FlutterBasicMessageChannel *channel = FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
[FlutterBasicMessageChannel messageChannelWithName:
messageChannelWithName:@"dev.flutter.pigeon.HostBookApi.finishEditingBook" @"dev.flutter.pigeon.HostBookApi.finishEditingBook"
binaryMessenger:binaryMessenger]; binaryMessenger:binaryMessenger
codec:BKHostBookApiGetCodec()];
if (api) { if (api) {
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSCAssert([api respondsToSelector:@selector(finishEditingBookBook:
FlutterError *error; error:)],
BKBook *input = [BKBook fromMap:message]; @"BKHostBookApi api doesn't respond to "
[api finishEditingBook:input error:&error]; @"@selector(finishEditingBookBook:error:)");
callback(wrapResult(nil, error)); [channel
}]; setMessageHandler:^(id _Nullable message, FlutterReply callback) {
} NSArray *args = message;
else { BKBook *arg_book = args[0];
FlutterError *error;
[api finishEditingBookBook:arg_book error:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil]; [channel setMessageHandler:nil];
} }
} }

@ -19,7 +19,7 @@ EXTERNAL SOURCES:
:path: "../flutter_module_books/.ios/Flutter/FlutterPluginRegistrant" :path: "../flutter_module_books/.ios/Flutter/FlutterPluginRegistrant"
SPEC CHECKSUMS: SPEC CHECKSUMS:
Flutter: ac41d61a47ae5bf8195a5598d2d63754888ec0d5 Flutter: bdfa2e8fe0e2880a2c6a58a0b1a8675c262a07af
flutter_module_books: 537fdde264c187fc97299f730dd35974055cac20 flutter_module_books: 537fdde264c187fc97299f730dd35974055cac20
FlutterPluginRegistrant: 2afd5ea46d3a949472c9b7da6462d8fbf7d8b16e FlutterPluginRegistrant: 2afd5ea46d3a949472c9b7da6462d8fbf7d8b16e

Loading…
Cancel
Save