Skip to content

Commit

Permalink
Merge pull request #7 from prokopsimek/master
Browse files Browse the repository at this point in the history
feat: upgrade to be compatible with Dart 3
  • Loading branch information
ViolanteCodes authored Sep 6, 2023
2 parents 4d0675a + 0b37a74 commit 5c42f6d
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 144 deletions.
50 changes: 30 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,58 @@ For a comprehensive list of examples, check out the [API documentation](https://

Every resource is accessed via your butter instance:

Butter butter = Butter('YOUR_API_KEY');
```dart
Butter butter = Butter('YOUR_API_KEY');
OR
OR
var butter = Butter('YOUR_API_KEY');
var butter = Butter('YOUR_API_KEY');
```

Every resource method returns a Future:

// Get blog posts
butter.post.list({'page': '1', 'pageSize': '10'}).then((response) {
print(response);
});
```dart
// Get blog posts
butter.post.list({'page': '1', 'pageSize': '10'}).then((response) {
print(response);
});
```

## Pages

* page
* retrieve(page_type, page_slug[, params])
* list(page_type[, params])

// Get page
butter.page.retrieve('casestudy', 'acme-co').then((response) {
print(response);
});

```dart
// Get page
butter.page.retrieve('casestudy', 'acme-co').then((response) {
print(response);
});
```

## Content fields

* content
* retrieve(keys)

// Get FAQ
butter.content.retrieve(["demo-key"]).then((resp) {
print(resp);
});
```dart
// Get FAQ
butter.content.retrieve(["demo-key"]).then((resp) {
print(resp);
});
```

### Localization

Setup locales in the ButterCMS dashboard and fetch localized content using the locale option:

// Get FAQ
butter.content.retrieve(["faq"], {'locale': 'es'}).then((resp) {
print(resp);
});
```dart
// Get FAQ
butter.content.retrieve(["faq"], {'locale': 'es'}).then((resp) {
print(resp);
});
```

## Blog Engine

Expand Down
12 changes: 6 additions & 6 deletions lib/src/butter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class Butter {
/// The API token for Butter user
final String _apiKey;

Pages? page;
Content? content;
Posts? post;
Authors? author;
Categories? category;
Tags? tag;
late Pages page;
late Content content;
late Posts post;
late Authors author;
late Categories category;
late Tags tag;

Butter(this._apiKey) {
if (_apiKey == "") {
Expand Down
Loading

0 comments on commit 5c42f6d

Please sign in to comment.