Skip to content

Commit b671637

Browse files
authored
0.5.3 (#94)
* Remove test dependency. Unneeded and conflicts with latest flutter * Maintenance update
1 parent dfc42c3 commit b671637

12 files changed

+195
-68
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ addons:
99
- libstdc++6
1010
- fonts-droid
1111
before_script:
12-
- git clone https://github.com/flutter/flutter.git -b master --depth 1
12+
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
1313
- ./flutter/bin/flutter doctor
1414
script:
1515
- ./flutter/bin/flutter test --coverage --coverage-path=lcov.info

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.5.3
4+
5+
* Maintenance update
6+
* Remove dependency on test package, conflicts with latest Flutter
7+
* Update docs
8+
* Update example dependencies to latest versions
9+
* Apply stricter analysis options
10+
311
## 0.5.2
412

513
* Add `onDidChange` -- This callback will be run after the ViewModel has changed and the builder method is called

analysis_options.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,76 @@ analyzer:
22
strong-mode:
33
implicit-casts: false
44
implicit-dynamic: false
5+
linter:
6+
rules:
7+
- public_member_api_docs
8+
- annotate_overrides
9+
- avoid_empty_else
10+
- avoid_function_literals_in_foreach_calls
11+
- avoid_init_to_null
12+
- avoid_null_checks_in_equality_operators
13+
- avoid_relative_lib_imports
14+
- avoid_renaming_method_parameters
15+
- avoid_return_types_on_setters
16+
- avoid_returning_null
17+
- avoid_types_as_parameter_names
18+
- avoid_unused_constructor_parameters
19+
- await_only_futures
20+
- camel_case_types
21+
- cancel_subscriptions
22+
- cascade_invocations
23+
- comment_references
24+
- constant_identifier_names
25+
- control_flow_in_finally
26+
- directives_ordering
27+
- empty_catches
28+
- empty_constructor_bodies
29+
- empty_statements
30+
- hash_and_equals
31+
- implementation_imports
32+
- invariant_booleans
33+
- iterable_contains_unrelated_type
34+
- library_names
35+
- library_prefixes
36+
- list_remove_unrelated_type
37+
- no_adjacent_strings_in_list
38+
- no_duplicate_case_values
39+
- non_constant_identifier_names
40+
- null_closures
41+
- omit_local_variable_types
42+
- only_throw_errors
43+
- overridden_fields
44+
- package_api_docs
45+
- package_names
46+
- package_prefixed_library_names
47+
- prefer_adjacent_string_concatenation
48+
- prefer_collection_literals
49+
- prefer_conditional_assignment
50+
- prefer_const_constructors
51+
- prefer_contains
52+
- prefer_equal_for_default_values
53+
- prefer_final_fields
54+
- prefer_initializing_formals
55+
- prefer_interpolation_to_compose_strings
56+
- prefer_is_empty
57+
- prefer_is_not_empty
58+
- prefer_single_quotes
59+
- prefer_typing_uninitialized_variables
60+
- recursive_getters
61+
- slash_for_doc_comments
62+
- super_goes_last
63+
- test_types_in_equals
64+
- throw_in_finally
65+
- type_init_formals
66+
- unawaited_futures
67+
- unnecessary_brace_in_string_interps
68+
- unnecessary_const
69+
- unnecessary_getters_setters
70+
- unnecessary_lambdas
71+
- unnecessary_new
72+
- unnecessary_null_aware_assignments
73+
- unnecessary_statements
74+
- unnecessary_this
75+
- unrelated_type_equality_checks
76+
- use_rethrow_when_possible
77+
- valid_regexps

example/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Examples
2+
3+
* [Simple example](https://github.com/brianegan/flutter_redux/tree/master/example/counter) - a port of the standard "Counter Button" example from Flutter
4+
* [Github Search](https://github.com/brianegan/flutter_redux/tree/master/example/github_search) - an example of how to search as a user types, demonstrating both the Middleware and Epic approaches.

example/counter/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
}
88

99
dependencies {
10-
classpath 'com.android.tools.build:gradle:2.3.3'
10+
classpath 'com.android.tools.build:gradle:3.2.1'
1111
}
1212
}
1313

example/counter/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
analyzer:
2-
strong-mode: true
1+
analyzer:
+13-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
buildscript {
22
repositories {
33
jcenter()
4+
maven {
5+
url "https://maven.google.com"
6+
}
47
}
58

69
dependencies {
7-
classpath 'com.android.tools.build:gradle:2.2.3'
10+
classpath 'com.android.tools.build:gradle:3.2.1'
811
}
912
}
1013

1114
allprojects {
1215
repositories {
1316
jcenter()
17+
maven {
18+
url "https://maven.google.com"
19+
}
1420
}
1521
}
1622

17-
task clean(type: Delete) {
18-
delete rootProject.buildDir
23+
rootProject.buildDir = '../build'
24+
subprojects {
25+
project.buildDir = "${rootProject.buildDir}/${project.name}"
26+
project.evaluationDependsOn(':app')
1927
}
2028

21-
task wrapper(type: Wrapper) {
22-
gradleVersion = '2.14.1'
29+
task clean(type: Delete) {
30+
delete rootProject.buildDir
2331
}

example/github_search/pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ dependencies:
55
flutter:
66
sdk: flutter
77
flutter_redux: 0.5.0
8-
async: 2.0.7
9-
redux_epics: 0.9.0
10-
rxdart: 0.16.7
8+
async: 2.0.8
9+
redux_epics: 0.10.3
10+
rxdart: ^0.20.0
1111

1212

1313
# For information on the generic Dart part of this file, see the

lib/flutter_redux.dart

+41-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import 'package:redux/redux.dart';
1212
class StoreProvider<S> extends InheritedWidget {
1313
final Store<S> _store;
1414

15+
/// Create a [StoreProvider] by passing in the required [store] and [child]
16+
/// parameters.
1517
const StoreProvider({
1618
Key key,
1719
@required Store<S> store,
@@ -21,10 +23,28 @@ class StoreProvider<S> extends InheritedWidget {
2123
_store = store,
2224
super(key: key, child: child);
2325

26+
/// A method that can be called by descendant Widgets to retrieve the Store
27+
/// from the StoreProvider.
28+
///
29+
/// Important: When using this method, pass through complete type information
30+
/// or Flutter will be unable to find the correct StoreProvider!
31+
///
32+
/// ### Example
33+
///
34+
/// ```
35+
/// class MyWidget extends StatelessWidget {
36+
/// @override
37+
/// Widget build(BuildContext context) {
38+
/// final store = StoreProvider.of<int>(context);
39+
///
40+
/// return Text('${store.state}');
41+
/// }
42+
/// }
43+
/// ```
2444
static Store<S> of<S>(BuildContext context) {
2545
final type = _typeOf<StoreProvider<S>>();
26-
final StoreProvider<S> provider =
27-
context.inheritFromWidgetOfExactType(type);
46+
final provider =
47+
context.inheritFromWidgetOfExactType(type) as StoreProvider<S>;
2848

2949
if (provider == null) throw StoreProviderError(type);
3050

@@ -35,7 +55,8 @@ class StoreProvider<S> extends InheritedWidget {
3555
static Type _typeOf<T>() => T;
3656

3757
@override
38-
bool updateShouldNotify(StoreProvider<S> old) => _store != old._store;
58+
bool updateShouldNotify(StoreProvider<S> oldWidget) =>
59+
_store != oldWidget._store;
3960
}
4061

4162
/// Build a Widget using the [BuildContext] and [ViewModel]. The [ViewModel] is
@@ -109,7 +130,7 @@ typedef OnDidChangeCallback<ViewModel> = void Function(ViewModel viewModel);
109130

110131
/// A function that will be run after the Widget is built the first time.
111132
///
112-
/// This function is passed the initial `ViewModel` created by the [converter]
133+
/// This function is passed the initial `ViewModel` created by the `converter`
113134
/// function.
114135
///
115136
/// This can be useful for starting certain animations, such as showing
@@ -208,6 +229,12 @@ class StoreConnector<S, ViewModel> extends StatelessWidget {
208229
/// Snackbars, after the Widget is built the first time.
209230
final OnInitialBuildCallback<ViewModel> onInitialBuild;
210231

232+
/// Create a [StoreConnector] by passing in the required [converter] and
233+
/// [builder] functions.
234+
///
235+
/// You can also specify a number of additional parameters that allow you to
236+
/// modify the behavior of the StoreConnector. Please see the documentation
237+
/// for each option for more info.
211238
StoreConnector({
212239
Key key,
213240
@required this.builder,
@@ -296,6 +323,7 @@ class StoreBuilder<S> extends StatelessWidget {
296323
/// Snackbars, after the Widget is built the first time.
297324
final OnInitialBuildCallback<Store<S>> onInitialBuild;
298325

326+
/// Create's a Widget based on the Store.
299327
StoreBuilder({
300328
Key key,
301329
@required this.builder,
@@ -401,7 +429,7 @@ class _StoreStreamListenerState<S, ViewModel>
401429
});
402430
}
403431

404-
Stream<S> _stream = widget.store.onChange;
432+
var _stream = widget.store.onChange;
405433

406434
if (widget.ignoreChange != null) {
407435
_stream = _stream.where((state) => !widget.ignoreChange(state));
@@ -454,15 +482,22 @@ class _StoreStreamListenerState<S, ViewModel>
454482
}
455483
}
456484

485+
/// If the StoreProvider.of method fails, this error will be thrown.
486+
///
487+
/// Often, when the `of` method fails, it is difficult to understand why since
488+
/// there can be multiple causes. This error explains those causes so the user
489+
/// can understand and fix the issue.
457490
class StoreProviderError extends Error {
491+
/// The type of the class the user tried to retrieve
458492
Type type;
459493

494+
/// Creates a StoreProviderError
460495
StoreProviderError(this.type);
461496

497+
@override
462498
String toString() {
463499
return '''Error: No $type found. To fix, please try:
464500
465-
* Using Dart 2 (required) by using the --preview-dart-2 flag
466501
* Wrapping your MaterialApp with the StoreProvider<State>,
467502
rather than an individual Route
468503
* Providing full type information to your Store<State>,

pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_redux
2-
description: A library that connects Widgets to a Redux Store
3-
version: 0.5.2
2+
description: A set of utility Widgets that Provide and Connect to a Redux Store
3+
version: 0.5.3
44
author: Brian Egan <[email protected]>
55
homepage: https://github.com/brianegan/flutter_redux
66

@@ -16,4 +16,4 @@ dependencies:
1616
dev_dependencies:
1717
flutter_test:
1818
sdk: flutter
19-
test: ">=0.12.30+3 <0.13.0"
19+
mockito: ^4.0.0

0 commit comments

Comments
 (0)