Skip to content

Commit 69edf82

Browse files
committed
chore: Add auto_updater_platform_interface package
1 parent 454274f commit 69edf82

File tree

10 files changed

+196
-0
lines changed

10 files changed

+196
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
build/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "7482962148e8d758338d8a28f589f317e1e42ba4"
8+
channel: "stable"
9+
10+
project_type: plugin
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 7482962148e8d758338d8a28f589f317e1e42ba4
17+
base_revision: 7482962148e8d758338d8a28f589f317e1e42ba4
18+
19+
# User provided section
20+
21+
# List of Local paths (relative to this file) that should be
22+
# ignored by the migrate tool.
23+
#
24+
# Files that are not part of the templates will be ignored by default.
25+
unmanaged_files:
26+
- 'lib/main.dart'
27+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.2.0
2+
3+
* First release.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2024 LiJianying <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# auto_updater_platform_interface
2+
3+
[![pub version][pub-image]][pub-url]
4+
5+
[pub-image]: https://img.shields.io/pub/v/auto_updater_platform_interface.svg
6+
[pub-url]: https://pub.dev/packages/auto_updater_platform_interface
7+
8+
A common platform interface for the [auto_updater](https://pub.dev/packages/auto_updater) plugin.
9+
10+
## Usage
11+
12+
To implement a new platform-specific implementation of auto_updater, extend `AutoUpdaterPlatform` with an implementation that performs the platform-specific behavior, and when you register your plugin, set the default `AutoUpdaterPlatform` by calling `AutoUpdaterPlatform.instance = MyPlatformAutoUpdater()`.
13+
14+
## License
15+
16+
[MIT](./LICENSE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:mostly_reasonable_lints/flutter.yaml
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library auto_updater_platform_interface;
2+
3+
export 'src/auto_updater_method_channel.dart';
4+
export 'src/auto_updater_platform_interface.dart';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:auto_updater_platform_interface/src/auto_updater_platform_interface.dart';
2+
import 'package:flutter/foundation.dart';
3+
import 'package:flutter/services.dart';
4+
5+
/// An implementation of [AutoUpdaterPlatform] that uses method channels.
6+
class MethodChannelAutoUpdater extends AutoUpdaterPlatform {
7+
/// The method channel used to interact with the native platform.
8+
@visibleForTesting
9+
final methodChannel = const MethodChannel(
10+
'dev.leanflutter.plugins/auto_updater',
11+
);
12+
13+
@override
14+
Future<void> setFeedURL(String feedUrl) async {
15+
final Map<String, dynamic> arguments = {
16+
'feedURL': feedUrl,
17+
};
18+
await methodChannel.invokeMethod('setFeedURL', arguments);
19+
}
20+
21+
@override
22+
Future<void> checkForUpdates({bool? inBackground}) async {
23+
final Map<String, dynamic> arguments = {
24+
'inBackground': inBackground ?? false,
25+
};
26+
await methodChannel.invokeMethod('checkForUpdates', arguments);
27+
}
28+
29+
@override
30+
Future<void> setScheduledCheckInterval(int interval) async {
31+
final Map<String, dynamic> arguments = {
32+
'interval': interval,
33+
};
34+
await methodChannel.invokeMethod('setScheduledCheckInterval', arguments);
35+
}
36+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import 'package:auto_updater_platform_interface/src/auto_updater_method_channel.dart';
2+
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
3+
4+
abstract class AutoUpdaterPlatform extends PlatformInterface {
5+
/// Constructs a AutoUpdaterPlatform.
6+
AutoUpdaterPlatform() : super(token: _token);
7+
8+
static final Object _token = Object();
9+
10+
static AutoUpdaterPlatform _instance = MethodChannelAutoUpdater();
11+
12+
/// The default instance of [AutoUpdaterPlatform] to use.
13+
///
14+
/// Defaults to [MethodChannelAutoUpdater].
15+
static AutoUpdaterPlatform get instance => _instance;
16+
17+
/// Platform-specific implementations should set this with their own
18+
/// platform-specific class that extends [AutoUpdaterPlatform] when
19+
/// they register themselves.
20+
static set instance(AutoUpdaterPlatform instance) {
21+
PlatformInterface.verifyToken(instance, _token);
22+
_instance = instance;
23+
}
24+
25+
/// Sets the url and initialize the auto updater.
26+
Future<void> setFeedURL(String feedUrl) async {
27+
throw UnimplementedError('setFeedURL() has not been implemented.');
28+
}
29+
30+
/// Asks the server whether there is an update. You must call setFeedURL before using this API.
31+
Future<void> checkForUpdates({bool? inBackground}) async {
32+
throw UnimplementedError('checkForUpdates() has not been implemented.');
33+
}
34+
35+
/// Sets the auto update check interval, default 86400, minimum 3600, 0 to disable update
36+
Future<void> setScheduledCheckInterval(int interval) async {
37+
throw UnimplementedError(
38+
'setScheduledCheckInterval() has not been implemented.',
39+
);
40+
}
41+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: auto_updater_platform_interface
2+
description: A common platform interface for the auto_updater plugin.
3+
version: 0.2.0
4+
homepage: https://github.com/leanflutter/auto_updater/blob/main/packages/auto_updater_platform_interface
5+
6+
environment:
7+
sdk: '>=3.0.0 <4.0.0'
8+
flutter: '>=3.3.0'
9+
10+
dependencies:
11+
flutter:
12+
sdk: flutter
13+
plugin_platform_interface: ^2.1.8
14+
15+
dev_dependencies:
16+
flutter_test:
17+
sdk: flutter
18+
mostly_reasonable_lints: ^0.1.1

0 commit comments

Comments
 (0)