Skip to content

Commit 5c42f6d

Browse files
Merge pull request #7 from prokopsimek/master
feat: upgrade to be compatible with Dart 3
2 parents 4d0675a + 0b37a74 commit 5c42f6d

File tree

4 files changed

+179
-144
lines changed

4 files changed

+179
-144
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,58 @@ For a comprehensive list of examples, check out the [API documentation](https://
1010

1111
Every resource is accessed via your butter instance:
1212

13-
Butter butter = Butter('YOUR_API_KEY');
13+
```dart
14+
Butter butter = Butter('YOUR_API_KEY');
1415
15-
OR
16+
OR
1617
17-
var butter = Butter('YOUR_API_KEY');
18+
var butter = Butter('YOUR_API_KEY');
19+
```
1820

1921
Every resource method returns a Future:
2022

21-
// Get blog posts
22-
butter.post.list({'page': '1', 'pageSize': '10'}).then((response) {
23-
print(response);
24-
});
23+
```dart
24+
// Get blog posts
25+
butter.post.list({'page': '1', 'pageSize': '10'}).then((response) {
26+
print(response);
27+
});
28+
```
2529

2630
## Pages
2731

2832
* page
2933
* retrieve(page_type, page_slug[, params])
3034
* list(page_type[, params])
31-
32-
// Get page
33-
butter.page.retrieve('casestudy', 'acme-co').then((response) {
34-
print(response);
35-
});
35+
36+
```dart
37+
// Get page
38+
butter.page.retrieve('casestudy', 'acme-co').then((response) {
39+
print(response);
40+
});
41+
```
3642

3743
## Content fields
3844

3945
* content
4046
* retrieve(keys)
4147

42-
// Get FAQ
43-
butter.content.retrieve(["demo-key"]).then((resp) {
44-
print(resp);
45-
});
48+
```dart
49+
// Get FAQ
50+
butter.content.retrieve(["demo-key"]).then((resp) {
51+
print(resp);
52+
});
53+
```
4654

4755
### Localization
4856

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

51-
// Get FAQ
52-
butter.content.retrieve(["faq"], {'locale': 'es'}).then((resp) {
53-
print(resp);
54-
});
59+
```dart
60+
// Get FAQ
61+
butter.content.retrieve(["faq"], {'locale': 'es'}).then((resp) {
62+
print(resp);
63+
});
64+
```
5565

5666
## Blog Engine
5767

lib/src/butter.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ class Butter {
99
/// The API token for Butter user
1010
final String _apiKey;
1111

12-
Pages? page;
13-
Content? content;
14-
Posts? post;
15-
Authors? author;
16-
Categories? category;
17-
Tags? tag;
12+
late Pages page;
13+
late Content content;
14+
late Posts post;
15+
late Authors author;
16+
late Categories category;
17+
late Tags tag;
1818

1919
Butter(this._apiKey) {
2020
if (_apiKey == "") {

0 commit comments

Comments
 (0)