Skip to content

0.5.3 #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ addons:
- libstdc++6
- fonts-droid
before_script:
- git clone https://github.com/flutter/flutter.git -b master --depth 1
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- ./flutter/bin/flutter doctor
script:
- ./flutter/bin/flutter test --coverage --coverage-path=lcov.info
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.5.3

* Maintenance update
* Remove dependency on test package, conflicts with latest Flutter
* Update docs
* Update example dependencies to latest versions
* Apply stricter analysis options

## 0.5.2

* Add `onDidChange` -- This callback will be run after the ViewModel has changed and the builder method is called
Expand Down
73 changes: 73 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,76 @@ analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
- public_member_api_docs
- annotate_overrides
- avoid_empty_else
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_types_as_parameter_names
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_types
- cancel_subscriptions
- cascade_invocations
- comment_references
- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
- null_closures
- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_initializing_formals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- recursive_getters
- slash_for_doc_comments
- super_goes_last
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unawaited_futures
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
4 changes: 4 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Examples

* [Simple example](https://github.com/brianegan/flutter_redux/tree/master/example/counter) - a port of the standard "Counter Button" example from Flutter
* [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.
2 changes: 1 addition & 1 deletion example/counter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
3 changes: 1 addition & 2 deletions example/github_search/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
analyzer:
strong-mode: true
analyzer:
18 changes: 13 additions & 5 deletions example/github_search/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}

task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
task clean(type: Delete) {
delete rootProject.buildDir
}
6 changes: 3 additions & 3 deletions example/github_search/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dependencies:
flutter:
sdk: flutter
flutter_redux: 0.5.0
async: 2.0.7
redux_epics: 0.9.0
rxdart: 0.16.7
async: 2.0.8
redux_epics: 0.10.3
rxdart: ^0.20.0


# For information on the generic Dart part of this file, see the
Expand Down
47 changes: 41 additions & 6 deletions lib/flutter_redux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:redux/redux.dart';
class StoreProvider<S> extends InheritedWidget {
final Store<S> _store;

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

/// A method that can be called by descendant Widgets to retrieve the Store
/// from the StoreProvider.
///
/// Important: When using this method, pass through complete type information
/// or Flutter will be unable to find the correct StoreProvider!
///
/// ### Example
///
/// ```
/// class MyWidget extends StatelessWidget {
/// @override
/// Widget build(BuildContext context) {
/// final store = StoreProvider.of<int>(context);
///
/// return Text('${store.state}');
/// }
/// }
/// ```
static Store<S> of<S>(BuildContext context) {
final type = _typeOf<StoreProvider<S>>();
final StoreProvider<S> provider =
context.inheritFromWidgetOfExactType(type);
final provider =
context.inheritFromWidgetOfExactType(type) as StoreProvider<S>;

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

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

@override
bool updateShouldNotify(StoreProvider<S> old) => _store != old._store;
bool updateShouldNotify(StoreProvider<S> oldWidget) =>
_store != oldWidget._store;
}

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

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

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

/// Create's a Widget based on the Store.
StoreBuilder({
Key key,
@required this.builder,
Expand Down Expand Up @@ -401,7 +429,7 @@ class _StoreStreamListenerState<S, ViewModel>
});
}

Stream<S> _stream = widget.store.onChange;
var _stream = widget.store.onChange;

if (widget.ignoreChange != null) {
_stream = _stream.where((state) => !widget.ignoreChange(state));
Expand Down Expand Up @@ -454,15 +482,22 @@ class _StoreStreamListenerState<S, ViewModel>
}
}

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

/// Creates a StoreProviderError
StoreProviderError(this.type);

@override
String toString() {
return '''Error: No $type found. To fix, please try:

* Using Dart 2 (required) by using the --preview-dart-2 flag
* Wrapping your MaterialApp with the StoreProvider<State>,
rather than an individual Route
* Providing full type information to your Store<State>,
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_redux
description: A library that connects Widgets to a Redux Store
version: 0.5.2
description: A set of utility Widgets that Provide and Connect to a Redux Store
version: 0.5.3
author: Brian Egan <[email protected]>
homepage: https://github.com/brianegan/flutter_redux

Expand All @@ -16,4 +16,4 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
test: ">=0.12.30+3 <0.13.0"
mockito: ^4.0.0
Loading