chore: delete old counter example, dart_bindings, and dart_cli (#35)

* chore: delete old counter example

* delete dart_bindings and dart_cli
This commit is contained in:
Bryan Oltman
2023-06-20 10:38:09 -04:00
committed by GitHub
parent f85eda8173
commit 0057c7ea8d
37 changed files with 0 additions and 1308 deletions
-7
View File
@@ -1,7 +0,0 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
-6
View File
@@ -1,6 +0,0 @@
# dart_bindings
Dart bindings for the updater library.
This presumably eventually either gets published to pub.dev, or more likely
ends up as dart:shorebird or something included with the Shorebird SDK.
-30
View File
@@ -1,30 +0,0 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
-112
View File
@@ -1,112 +0,0 @@
// This entire file could be easily autogenerated.
// Probably https://pub.dev/packages/ffigen would work.
import 'dart:ffi' as ffi;
import 'package:ffi/ffi.dart';
// This must be kept in sync with the C struct in updater.h.
// Including *in the same order* as the C struct.
class AppParameters extends ffi.Struct {
external ffi.Pointer<Utf8> channel;
// ignore: non_constant_identifier_names
external ffi.Pointer<Utf8> app_id;
// ignore: non_constant_identifier_names
external ffi.Pointer<Utf8> base_version;
// ignore: non_constant_identifier_names
external ffi.Pointer<Utf8> update_url;
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Pointer<Utf8>> original_libapp_paths;
@ffi.Int8()
// ignore: non_constant_identifier_names
external int original_libapp_paths_size;
// ignore: non_constant_identifier_names
external ffi.Pointer<Utf8> cache_dir;
static ffi.Pointer<AppParameters> allocate({
required String appId,
required String version,
required String channel,
required String? updateUrl,
required List<String> libappPaths,
required String libflutterPath,
required String cacheDir,
}) {
var config = calloc<AppParameters>();
config.ref.app_id = appId.toNativeUtf8();
config.ref.base_version = version.toNativeUtf8();
config.ref.channel = channel.toNativeUtf8();
if (updateUrl != null) {
config.ref.update_url = updateUrl.toNativeUtf8();
}
config.ref.original_libapp_paths = calloc<ffi.Pointer<Utf8>>(
libappPaths.length,
);
for (var i = 0; i < libappPaths.length; i++) {
config.ref.original_libapp_paths[i] = libappPaths[i].toNativeUtf8();
}
config.ref.cache_dir = cacheDir.toNativeUtf8();
return config;
}
static void free(ffi.Pointer<AppParameters> config) {
calloc.free(config.ref.app_id);
calloc.free(config.ref.base_version);
calloc.free(config.ref.channel);
calloc.free(config.ref.update_url);
// Free all paths in original_libapp_path.
for (var i = 0; i < config.ref.original_libapp_paths_size; i++) {
calloc.free(config.ref.original_libapp_paths[i]);
}
calloc.free(config.ref.original_libapp_paths);
calloc.free(config.ref.cache_dir);
calloc.free(config);
}
}
typedef _GetBoolFunc = ffi.Bool Function();
typedef GetBool = bool Function();
typedef _GetStringFunc = ffi.Pointer<Utf8> Function();
typedef GetString = ffi.Pointer<Utf8> Function();
typedef _GetVoidFunc = ffi.Void Function();
typedef GetVoid = void Function();
typedef _SBInitFunc = ffi.Void Function(ffi.Pointer<AppParameters> config);
typedef SBInit = void Function(ffi.Pointer<AppParameters> config);
typedef _FreeStringFunc = ffi.Void Function(ffi.Pointer<Utf8> str);
typedef FreeString = void Function(ffi.Pointer<Utf8> str);
class UpdaterBindings {
final ffi.DynamicLibrary library;
late SBInit init;
late GetBool checkForUpdate;
late GetString activeVersion;
late GetString activePath;
late FreeString freeString;
late GetVoid update;
UpdaterBindings(this.library) {
// None of these call back into Dart, so they're all safely "isLeaf: true".
init = library.lookupFunction<_SBInitFunc, SBInit>('shorebird_init',
isLeaf: true);
activeVersion = library.lookupFunction<_GetStringFunc, GetString>(
'shorebird_active_version',
isLeaf: true);
activePath = library.lookupFunction<_GetStringFunc, GetString>(
'shorebird_active_path',
isLeaf: true);
freeString = library.lookupFunction<_FreeStringFunc, FreeString>(
'shorebird_free_string',
isLeaf: true);
checkForUpdate = library.lookupFunction<_GetBoolFunc, GetBool>(
'shorebird_check_for_update',
isLeaf: true);
update = library.lookupFunction<_GetVoidFunc, GetVoid>('shorebird_update',
isLeaf: true);
}
}
-108
View File
@@ -1,108 +0,0 @@
import 'dart:ffi' as ffi;
import 'dart:io';
import 'package:ffi/ffi.dart';
import 'package:path/path.dart' as path;
import 'src/bindings.dart';
class Updater {
Updater();
static UpdaterBindings? _bindings;
static ffi.DynamicLibrary _loadLibraryInDirectory(
{required String directory, required String name}) {
if (Platform.isMacOS) {
return ffi.DynamicLibrary.open(path.join(directory, 'lib$name.dylib'));
}
if (Platform.isWindows) {
return ffi.DynamicLibrary.open(path.join(directory, '$name.dll'));
}
// Assume everything else follows the Linux pattern.
return ffi.DynamicLibrary.open(path.join(directory, 'lib$name.so'));
}
static loadLibrary({required String name, required String directory}) {
if (_bindings != null) {
throw Exception('Library already loaded.');
}
final updater = _loadLibraryInDirectory(directory: directory, name: name);
_bindings = UpdaterBindings(updater);
}
static loadFlutterLibrary() {
if (_bindings != null) {
throw Exception('Library already loaded.');
}
final updater = ffi.DynamicLibrary.process();
_bindings = UpdaterBindings(updater);
}
static UpdaterBindings get bindings {
if (_bindings == null) {
throw Exception('Must call loadLibrary() first.');
}
return _bindings!;
}
// This is only used when called from a Dart command line.
// Shorebird will have initialized the library already for you when
// inside a Flutter app.
static void initUpdaterLibrary({
required String appId,
required String version,
required String channel,
required String? updateUrl,
required List<String> baseLibraryPaths,
required String vmPath,
required String cacheDir,
}) {
var config = AppParameters.allocate(
appId: appId,
version: version,
channel: channel,
updateUrl: updateUrl,
libappPaths: baseLibraryPaths,
libflutterPath: vmPath,
cacheDir: cacheDir,
);
try {
bindings.init(config);
} finally {
AppParameters.free(config);
}
}
bool checkForUpdate() {
return bindings.checkForUpdate();
}
void update() {
return bindings.update();
}
String? _returnsMaybeString(ffi.Pointer<Utf8> Function() f) {
ffi.Pointer<Utf8> cString = ffi.Pointer<Utf8>.fromAddress(0);
cString = f();
if (cString.address == 0) {
return null;
}
try {
return cString.toDartString();
} finally {
// Using finally for two reasons:
// 1. it runs after the return (saving us a local)
// 2. it runs even if toDartString throws (which it shouldn't)
bindings.freeString(cString);
}
}
String? activeVersion() {
return _returnsMaybeString(bindings.activeVersion);
}
String? activePath() {
return _returnsMaybeString(bindings.activePath);
}
}
-16
View File
@@ -1,16 +0,0 @@
name: dart_bindings
description: dart bindings for Shorebird updater library
version: 1.0.0
environment:
sdk: '>=2.19.0 <4.0.0'
# Add regular dependencies here.
dependencies:
ffi: ^2.0.1
# path version must match that depended on by Flutter SDK.
path: ^1.8.2
dev_dependencies:
lints: ^2.0.0
test: ^1.21.0
-4
View File
@@ -1,4 +0,0 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
pubspec.lock
-1
View File
@@ -1 +0,0 @@
Command line application to test ffi wrapping of updater library.
-30
View File
@@ -1,30 +0,0 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
-137
View File
@@ -1,137 +0,0 @@
import 'dart:convert';
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:dart_bindings/updater.dart';
import 'package:path/path.dart' as path;
void main(List<String> args) async {
var directory = path.join(Directory.current.path, 'target', 'debug');
Updater.loadLibrary(directory: directory, name: "updater");
Updater.initUpdaterLibrary(
appId: 'demo',
version: '1.0.0',
channel: 'stable',
updateUrl: null,
baseLibraryPaths: ['libapp.so'],
vmPath: Platform.executable,
cacheDir: 'updater_cache',
);
var updater = Updater();
final runner = CommandRunner<void>('updater', 'Updater CLI')
..addCommand(CheckForUpdate(updater))
..addCommand(PrintVersion(updater))
..addCommand(PrintPath(updater))
..addCommand(Update(updater))
..addCommand(Run(updater));
await runner.run(args);
}
class CheckForUpdate extends Command<void> {
final Updater updater;
CheckForUpdate(this.updater);
@override
final name = 'check';
@override
final description = 'Check for an update.';
@override
void run() {
var result = updater.checkForUpdate();
if (result) {
print('Update available');
} else {
print('No update available');
}
}
}
class PrintVersion extends Command<void> {
final Updater updater;
PrintVersion(this.updater);
@override
final name = 'version';
@override
final description = 'Print current installed version.';
@override
void run() {
print(updater.activeVersion());
}
}
class PrintPath extends Command<void> {
final Updater updater;
PrintPath(this.updater);
@override
final name = 'path';
@override
final description = 'Print current installed path.';
@override
void run() {
print(updater.activePath());
}
}
class Update extends Command<void> {
final Updater updater;
Update(this.updater);
@override
final name = 'update';
@override
final description = 'Update to the latest version.';
@override
void run() {
updater.update();
}
}
class Run extends Command<void> {
final Updater updater;
Run(this.updater) {
argParser.addFlag('update', abbr: 'u', help: 'Update before running.');
}
@override
final name = 'run';
@override
final description = 'Run the active version.';
@override
void run() async {
// This is a basic demo of what this might look like.
// Real callers wouldn't likely do this from Dart as there is no need
// to have two copies of the Dart VM running.
if (argResults!['update']) {
updater.update();
}
var path = updater.activePath();
if (path == null) {
print('No active version (should run the bundled version)');
return;
}
// Should this run update first?
print('Running $path');
// Is there a portable way to just "exec" and replace the current process?
var process = await Process.start(Platform.executable, ['run', path]);
process.stdout.transform(utf8.decoder).forEach(stdout.write);
process.stderr.transform(utf8.decoder).forEach(stderr.write);
// TODO: Handle stdin.
exit(await process.exitCode);
}
}
-18
View File
@@ -1,18 +0,0 @@
name: dart_cli
description: A sample command-line application.
version: 1.0.0
# repository: https://github.com/my_org/my_repo
publish_to: 'none'
environment:
sdk: ">=2.19.0 <4.0.0"
dependencies:
args: ^2.4.0
dart_bindings:
path: ../dart_bindings
path: ^1.8.3
dev_dependencies:
lints: ^2.0.0
test: ^1.21.0
-47
View File
@@ -1,47 +0,0 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
# Shorebird related
.shorebird/
-45
View File
@@ -1,45 +0,0 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
version:
revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
channel: master
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
- platform: android
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
- platform: ios
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
- platform: linux
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
- platform: macos
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
- platform: web
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
- platform: windows
create_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
base_revision: c4bc9d5f37b8a0e3fe5402f30659cb87c3dce3cb
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
-16
View File
@@ -1,16 +0,0 @@
# counter
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
-29
View File
@@ -1,29 +0,0 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
-13
View File
@@ -1,13 +0,0 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
-71
View File
@@ -1,71 +0,0 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.counter"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
@@ -1,36 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.counter">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:label="counter"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
@@ -1,6 +0,0 @@
package com.example.counter
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
@@ -1,8 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.counter">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
-31
View File
@@ -1,31 +0,0 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
@@ -1,3 +0,0 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
@@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
-11
View File
@@ -1,11 +0,0 @@
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
-162
View File
@@ -1,162 +0,0 @@
// ignore_for_file: avoid_print
import 'dart:math';
import 'package:dart_bindings/updater.dart';
import 'package:flutter/material.dart';
void main() {
try {
Updater.loadFlutterLibrary();
var updater = Updater();
// Just to prove the bindings work at all:
print("active version: ${updater.activeVersion()}");
print("active path: ${updater.activePath()}");
} catch (e) {
print(
"Could not load shorebird updater library. Did you run with `shorebird run`?");
print("Error: $e");
}
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Shorebird Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Shorebird Updater Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
// Stub until https://github.com/shorebirdtech/shorebird/issues/123 is resolved.
class Update {
const Update(this.version, this.bytes);
final String version;
final int bytes;
}
class _MyHomePageState extends State<MyHomePage> {
String _fileSizeString(int bytes) {
const suffixes = ["b", "kb", "mb", "gb"];
final i = (log(bytes) / log(1024)).floor();
return ((bytes / pow(1024, i)).toStringAsFixed(1)) + suffixes[i];
}
void _showUpdateBanner() {
const update = Update("1.2.3", 1234567);
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
padding: const EdgeInsets.all(20),
content: Text('A new version (${update.version}) is available.\n'
'Download size: ${_fileSizeString(update.bytes)}'),
leading: const Icon(Icons.update),
backgroundColor: Colors.green,
// Android button order appears to be "negative", "neutral", "positive".
actions: <Widget>[
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: const Text('LATER'),
),
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
_showProgressBanner();
},
child: const Text('INSTALL'),
),
],
));
}
void _showProgressBanner() {
final controller =
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
content: const LinearProgressIndicator(
value: null,
semanticsLabel: 'Download progress',
),
leading: const Icon(Icons.update),
backgroundColor: Colors.green,
actions: <Widget>[
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: const Text('HIDE'),
),
],
));
Future.delayed(const Duration(seconds: 5)).then((_) {
controller.close();
_showRestartBanner();
});
}
void _showRestartBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
content: const Text('Restart to apply update.'),
leading: const Icon(Icons.update),
backgroundColor: Colors.green,
// Android button order appears to be "negative", "neutral", "positive".
actions: <Widget>[
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: const Text('LATER'),
),
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
// Need a restart API.
// https://github.com/shorebirdtech/shorebird/issues/117
},
child: const Text('RESTART'),
),
],
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Text(
"This demo shows how to call the Shorebird updater library from Dart."),
],
),
),
floatingActionButton: FloatingActionButton(
tooltip: 'Show Update Banner',
onPressed: _showUpdateBanner,
child: const Icon(Icons.update),
),
);
}
}
-203
View File
@@ -1,203 +0,0 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
url: "https://pub.dev"
source: hosted
version: "2.10.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
url: "https://pub.dev"
source: hosted
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
url: "https://pub.dev"
source: hosted
version: "1.17.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
url: "https://pub.dev"
source: hosted
version: "1.0.5"
dart_bindings:
dependency: "direct main"
description:
path: "../../dart_bindings"
relative: true
source: path
version: "1.0.0"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.dev"
source: hosted
version: "0.6.5"
lints:
dependency: transitive
description:
name: lints
sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
url: "https://pub.dev"
source: hosted
version: "0.12.13"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.dev"
source: hosted
version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
path:
dependency: transitive
description:
name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
url: "https://pub.dev"
source: hosted
version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.dev"
source: hosted
version: "1.9.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
url: "https://pub.dev"
source: hosted
version: "0.4.16"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
sdks:
dart: ">=2.19.0 <3.0.0"
-92
View File
@@ -1,92 +0,0 @@
name: counter
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
# HACK: Remove +1 which confuses `shorebird publish` for now.
version: 1.0.0
environment:
sdk: ">=2.19.0 <4.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
dart_bindings:
path: ../../dart_bindings
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- shorebird.yaml
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
-1
View File
@@ -1 +0,0 @@
app_id: shorebird-counter