Skip to content

Commit 0421c51

Browse files
Łukasz Rejmanbrianegan
authored andcommitted
Fix GitHub Search example crash on exceeding rate limit (#162)
* Replace GithubApi with GithubClient * Update .gitignore for examples * Add launch config for Visual Studio Code to make it easier to launch examples in the IDE * Use SearchErrorWidget for SearchError state
1 parent 6e686a0 commit 0421c51

File tree

5 files changed

+162
-12
lines changed

5 files changed

+162
-12
lines changed

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Counter",
9+
"request": "launch",
10+
"type": "dart",
11+
"program": "example/counter/lib/main.dart"
12+
},
13+
{
14+
"name": "Github Search",
15+
"request": "launch",
16+
"type": "dart",
17+
"program": "example/github_search/lib/main.dart"
18+
}
19+
]
20+
}

example/counter/.gitignore

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,73 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
16
.DS_Store
27
.atom/
3-
.idea
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
427
.packages
28+
.pub-cache/
529
.pub/
6-
build/
7-
ios/.generated/
8-
packages
9-
pubspec.lock
10-
.flutter-plugins
30+
/build/
31+
32+
# Android related
33+
**/android/**/gradle-wrapper.jar
34+
**/android/.gradle
35+
**/android/captures/
36+
**/android/gradlew
37+
**/android/gradlew.bat
38+
**/android/local.properties
39+
**/android/**/GeneratedPluginRegistrant.java
40+
41+
# iOS/XCode related
42+
**/ios/**/*.mode1v3
43+
**/ios/**/*.mode2v3
44+
**/ios/**/*.moved-aside
45+
**/ios/**/*.pbxuser
46+
**/ios/**/*.perspectivev3
47+
**/ios/**/*sync/
48+
**/ios/**/.sconsign.dblite
49+
**/ios/**/.tags*
50+
**/ios/**/.vagrant/
51+
**/ios/**/DerivedData/
52+
**/ios/**/Icon?
53+
**/ios/**/Pods/
54+
**/ios/**/.symlinks/
55+
**/ios/**/profile
56+
**/ios/**/xcuserdata
57+
**/ios/.generated/
58+
**/ios/Flutter/App.framework
59+
**/ios/Flutter/Flutter.framework
60+
**/ios/Flutter/Generated.xcconfig
61+
**/ios/Flutter/app.flx
62+
**/ios/Flutter/app.zip
63+
**/ios/Flutter/flutter_assets/
64+
**/ios/Flutter/flutter_export_environment.sh
65+
**/ios/ServiceDefinitions.json
66+
**/ios/Runner/GeneratedPluginRegistrant.*
67+
68+
# Exceptions to above rules.
69+
!**/ios/**/default.mode1v3
70+
!**/ios/**/default.mode2v3
71+
!**/ios/**/default.pbxuser
72+
!**/ios/**/default.perspectivev3
73+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

example/github_search/.gitignore

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,73 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
16
.DS_Store
27
.atom/
3-
.idea
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
427
.packages
28+
.pub-cache/
529
.pub/
6-
build/
7-
ios/.generated/
8-
packages
9-
pubspec.lock
30+
/build/
31+
32+
# Android related
33+
**/android/**/gradle-wrapper.jar
34+
**/android/.gradle
35+
**/android/captures/
36+
**/android/gradlew
37+
**/android/gradlew.bat
38+
**/android/local.properties
39+
**/android/**/GeneratedPluginRegistrant.java
40+
41+
# iOS/XCode related
42+
**/ios/**/*.mode1v3
43+
**/ios/**/*.mode2v3
44+
**/ios/**/*.moved-aside
45+
**/ios/**/*.pbxuser
46+
**/ios/**/*.perspectivev3
47+
**/ios/**/*sync/
48+
**/ios/**/.sconsign.dblite
49+
**/ios/**/.tags*
50+
**/ios/**/.vagrant/
51+
**/ios/**/DerivedData/
52+
**/ios/**/Icon?
53+
**/ios/**/Pods/
54+
**/ios/**/.symlinks/
55+
**/ios/**/profile
56+
**/ios/**/xcuserdata
57+
**/ios/.generated/
58+
**/ios/Flutter/App.framework
59+
**/ios/Flutter/Flutter.framework
60+
**/ios/Flutter/Generated.xcconfig
61+
**/ios/Flutter/app.flx
62+
**/ios/Flutter/app.zip
63+
**/ios/Flutter/flutter_assets/
64+
**/ios/Flutter/flutter_export_environment.sh
65+
**/ios/ServiceDefinitions.json
66+
**/ios/Runner/GeneratedPluginRegistrant.*
67+
68+
# Exceptions to above rules.
69+
!**/ios/**/default.mode1v3
70+
!**/ios/**/default.mode2v3
71+
!**/ios/**/default.pbxuser
72+
!**/ios/**/default.perspectivev3
73+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

example/github_search/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main() {
1717
// One is implemented as a normal middleware, the other is implemented as
1818
// an epic for demonstration purposes.
1919

20-
// SearchMiddleware(GithubApi()),
20+
// SearchMiddleware(GithubClient()),
2121
EpicMiddleware<SearchState>(SearchEpic(GithubClient())),
2222
],
2323
);

example/github_search/lib/search_screen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_redux/flutter_redux.dart';
33
import 'package:github_search/redux.dart';
44
import 'package:github_search/search_empty_view.dart';
5+
import 'package:github_search/search_error_view.dart';
56
import 'package:github_search/search_initial_view.dart';
67
import 'package:github_search/search_loading_view.dart';
78
import 'package:github_search/search_result_view.dart';
@@ -57,6 +58,8 @@ class SearchScreen extends StatelessWidget {
5758
return SearchPopulatedView(state.result);
5859
} else if (state is SearchInitial) {
5960
return SearchInitialView();
61+
} else if (state is SearchError) {
62+
return SearchErrorWidget();
6063
}
6164

6265
throw ArgumentError('No view for state: $state');

0 commit comments

Comments
 (0)