forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shared_preferences] Convert macOS to Pigeon (flutter#6914)
* Add Pigeon and update Dart, based on iOS implementation * Update Swift implementation * Update Swift tests * Adjust Dart test and add Pigeon TODOs * Version bump * Format * Update to Pigeon 5.0 for Swift warning fix
- Loading branch information
1 parent
3a6f63b
commit 276cfd4
Showing
11 changed files
with
652 additions
and
233 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
packages/shared_preferences/shared_preferences_macos/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
packages/shared_preferences/shared_preferences_macos/lib/messages.g.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
// Autogenerated from Pigeon (v5.0.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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import | ||
import 'dart:async'; | ||
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; | ||
|
||
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; | ||
import 'package:flutter/services.dart'; | ||
|
||
class UserDefaultsApi { | ||
/// Constructor for [UserDefaultsApi]. 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. | ||
UserDefaultsApi({BinaryMessenger? binaryMessenger}) | ||
: _binaryMessenger = binaryMessenger; | ||
final BinaryMessenger? _binaryMessenger; | ||
|
||
static const MessageCodec<Object?> codec = StandardMessageCodec(); | ||
|
||
Future<void> remove(String arg_key) async { | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.UserDefaultsApi.remove', codec, | ||
binaryMessenger: _binaryMessenger); | ||
final List<Object?>? replyList = | ||
await channel.send(<Object?>[arg_key]) as List<Object?>?; | ||
if (replyList == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
); | ||
} else if (replyList.length > 1) { | ||
throw PlatformException( | ||
code: replyList[0]! as String, | ||
message: replyList[1] as String?, | ||
details: replyList[2], | ||
); | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
Future<void> setBool(String arg_key, bool arg_value) async { | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.UserDefaultsApi.setBool', codec, | ||
binaryMessenger: _binaryMessenger); | ||
final List<Object?>? replyList = | ||
await channel.send(<Object?>[arg_key, arg_value]) as List<Object?>?; | ||
if (replyList == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
); | ||
} else if (replyList.length > 1) { | ||
throw PlatformException( | ||
code: replyList[0]! as String, | ||
message: replyList[1] as String?, | ||
details: replyList[2], | ||
); | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
Future<void> setDouble(String arg_key, double arg_value) async { | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.UserDefaultsApi.setDouble', codec, | ||
binaryMessenger: _binaryMessenger); | ||
final List<Object?>? replyList = | ||
await channel.send(<Object?>[arg_key, arg_value]) as List<Object?>?; | ||
if (replyList == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
); | ||
} else if (replyList.length > 1) { | ||
throw PlatformException( | ||
code: replyList[0]! as String, | ||
message: replyList[1] as String?, | ||
details: replyList[2], | ||
); | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
Future<void> setValue(String arg_key, Object arg_value) async { | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.UserDefaultsApi.setValue', codec, | ||
binaryMessenger: _binaryMessenger); | ||
final List<Object?>? replyList = | ||
await channel.send(<Object?>[arg_key, arg_value]) as List<Object?>?; | ||
if (replyList == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
); | ||
} else if (replyList.length > 1) { | ||
throw PlatformException( | ||
code: replyList[0]! as String, | ||
message: replyList[1] as String?, | ||
details: replyList[2], | ||
); | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
Future<Map<String?, Object?>> getAll() async { | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.UserDefaultsApi.getAll', codec, | ||
binaryMessenger: _binaryMessenger); | ||
final List<Object?>? replyList = await channel.send(null) as List<Object?>?; | ||
if (replyList == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
); | ||
} else if (replyList.length > 1) { | ||
throw PlatformException( | ||
code: replyList[0]! as String, | ||
message: replyList[1] as String?, | ||
details: replyList[2], | ||
); | ||
} else if (replyList[0] == null) { | ||
throw PlatformException( | ||
code: 'null-error', | ||
message: 'Host platform returned null value for non-null return value.', | ||
); | ||
} else { | ||
return (replyList[0] as Map<Object?, Object?>?)!.cast<String?, Object?>(); | ||
} | ||
} | ||
|
||
Future<void> clear() async { | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.UserDefaultsApi.clear', codec, | ||
binaryMessenger: _binaryMessenger); | ||
final List<Object?>? replyList = await channel.send(null) as List<Object?>?; | ||
if (replyList == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
); | ||
} else if (replyList.length > 1) { | ||
throw PlatformException( | ||
code: replyList[0]! as String, | ||
message: replyList[1] as String?, | ||
details: replyList[2], | ||
); | ||
} else { | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.