-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e84cfb5
Showing
25 changed files
with
1,457 additions
and
0 deletions.
There are no files selected for viewing
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,94 @@ | ||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
# Remove the following pattern if you wish to check in your lock file | ||
pubspec.lock | ||
|
||
# Conventional directory for build outputs | ||
build/ | ||
|
||
# Directory created by dartdoc | ||
doc/api/ | ||
|
||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/artifacts | ||
# .idea/compiler.xml | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
### VisualStudioCode template | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
*.code-workspace | ||
|
||
## Test config | ||
test-unsplash-credentials.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 @@ | ||
## 0.1.0 | ||
|
||
- TODO |
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,45 @@ | ||
An unofficial client to for the [unsplash](https://unsplash.com) api. | ||
|
||
This is a work in progress. At the moment only **Photos.list** and **Photos.random** are | ||
implemented. | ||
|
||
## Usage | ||
|
||
A simple usage example: | ||
|
||
```dart | ||
import 'package:unsplash_client/client.dart'; | ||
void main() async { | ||
// Create a client. | ||
final client = UnsplashClient( | ||
settings: Settings( | ||
// Use the credentials from the developer portal. | ||
credentials: AppCredentials( | ||
accessKey: '...', | ||
secretKey: '...', | ||
) | ||
), | ||
); | ||
// Fetch 5 random photos. | ||
final response = await client.photos.random(count: 5).go(); | ||
// Check that the request was successful. | ||
if (!response.isOk) { | ||
throw 'Something is wrong: $response'; | ||
} | ||
// Do something with the photos. | ||
final photos = response.data; | ||
// Create a dynamically resized url. | ||
final resizedUrl = photos.first.urls.raw.resize( | ||
width: 400, | ||
height: 400, | ||
fit: ResizeFitMode.cover, | ||
format: ImageFormat.webp, | ||
); | ||
} | ||
``` |
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,10 @@ | ||
include: package:effective_dart/analysis_options.1.2.0.yaml | ||
|
||
linter: | ||
rules: | ||
- prefer_relative_imports | ||
|
||
analyzer: | ||
strong-mode: | ||
implicit-casts: false | ||
implicit-dynamic: false |
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,5 @@ | ||
export 'src/app_credentials.dart'; | ||
export 'src/client.dart'; | ||
export 'src/model/model.dart'; | ||
export 'src/photos.dart'; | ||
export 'src/dynamic_resize.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,63 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
/// Credentials for accessing the unsplash api, as a registered app. | ||
/// | ||
/// You need to [register](https://unsplash.com/developers) as a developer | ||
/// and create an usnplash app to get credentials. | ||
@immutable | ||
class AppCredentials { | ||
/// Creates [AppCredentials] from the given arguments. | ||
const AppCredentials({ | ||
@required this.accessKey, | ||
this.secretKey, | ||
}) : assert(accessKey != null); | ||
|
||
/// The access key of the app these [AppCredentials] belong to. | ||
final String accessKey; | ||
|
||
/// The secret key of the app these [AppCredentials] belong to. | ||
final String secretKey; | ||
|
||
/// Creates a copy of this instance, replacing non `null` fields. | ||
AppCredentials copyWith({ | ||
String accessKey, | ||
String secretKey, | ||
}) { | ||
return AppCredentials( | ||
accessKey: accessKey ?? this.accessKey, | ||
secretKey: secretKey ?? this.secretKey, | ||
); | ||
} | ||
|
||
/// Serializes this instance to json. | ||
Map<String, dynamic> toJson() { | ||
return <String, dynamic>{ | ||
'accessKey': accessKey, | ||
'secretKey': secretKey, | ||
}; | ||
} | ||
|
||
/// Deserializes [AppCredentials] from [json]. | ||
factory AppCredentials.fromJson(Map<String, dynamic> json) { | ||
return AppCredentials( | ||
accessKey: json['accessKey'] as String, | ||
secretKey: json['secretKey'] as String, | ||
); | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
other is AppCredentials && | ||
runtimeType == other.runtimeType && | ||
accessKey == other.accessKey && | ||
secretKey == other.secretKey; | ||
|
||
@override | ||
int get hashCode => accessKey.hashCode ^ secretKey.hashCode; | ||
|
||
@override | ||
String toString() { | ||
return 'Credentials{accessKey: $accessKey, secretKey: $secretKey}'; | ||
} | ||
} |
Oops, something went wrong.