Comments (5)
Ya this is just a warning, it should not impact anything. Still it would be nice if this could be patched soon.
from get_it_mixin.
It's just an unnecessary_non_null_assertion
warning in mixin_state.dart
. I did a pull request for the fix but then saw that there was already an old one. Mine has updated packages and stuff.
I don't think there are too many users of this package. I'm guessing that's the reason why Thomas is not spending too much time on it.
from get_it_mixin.
I did some more research since this is a showstopper for me.
The impact of this warning / error is as follows:
notifyListeners()
does somehow not work. I use it in a Scaffold with a BottomNavigationBar. This requires to detect if the selected (tab)item changes. The build
method of the widget is not immediately called. Sometimes it does rebuild after one minute or so!! Really strange.
So I have loaded a very old project which I used to learn how to work with get_it_mixin
. That is extremely simple and has no other packages than get_it / get_it_mixin
. It uses version 1.5.1. There no error is displayed and notifyListeners()
works just fine.
Looks like there is a problem with version 3.1.3. I tried to use an older version like 1.5.1 but that does not work because of dependencies. Also Version 2.0.0 seems to be to old. I also tried 3.1.0 but there the same error is shown. To me this looks like a dependency problem of recent version with latest versions of Android Studio and the Flutter SDK.
This is my pubspec.yaml file with the latest version and the error shown above:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
bottom_navy_bar: ^6.0.0
get_it: ^7.2.0
get_it_mixin: ^3.1.3
servicestack: ^2.0.0
font_awesome_flutter: ^9.1.0
hive: ^2.0.4
hive_flutter: ^1.1.0
path_provider: ^2.0.3
uuid: ^3.0.4
equatable: ^2.0.3
intl: ^0.17.0
tuple: ^2.0.0
flutter_layout_grid: ^1.0.3
device_info_plus: ^3.0.1
network_info_plus: ^2.0.2
flutter_slidable: ^1.1.0
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
build_runner: ^2.1.5
I also cleaned the public cache with flutter pub cache clean
and then ran flutter pub get
to make sure I do not have corrupted stuff in my .pub-cache
folder. However this did not help.
I have no idea what else I could try....
from get_it_mixin.
OK, I solved the problem of the changeNotifiers not being registered.
I used get
/getX
instead of watchOnly
. It looks like the listener is registered in watchOnly
and not in get
.
// final selectedTab = get<DashboardManager>().selectedTab; <====== THIS IS WRONG
final selectedTab = watchOnly((DashboardManager x) => x.selectedTab); <==== THIS IS CORRECT
However, this warning
../../../../Applications/flutter/.pub-cache/hosted/pub.dartlang.org/get_it_mixin-3.1.3/lib/src/mixin_state.dart:495:7: Warning: Operand of null-aware operation '!' has type 'void Function(BuildContext, AsyncSnapshot<R?>, void Function())' which excludes null.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../../Applications/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'AsyncSnapshot' is from 'package:flutter/src/widgets/async.dart' ('../../../../Applications/flutter/packages/flutter/lib/src/widgets/async.dart').
handler!(_element!, watch.lastValue!, watch.dispose);
^
remains with the latest Dart/Flutter versions.
from get_it_mixin.
Guys, really sorry about that I couldn't take care earlier of this.
Indeed @thommy66 get
really only gets and does not start to monitor changes.
from get_it_mixin.
Related Issues (20)
- get watch watchOnly getX watchX watchOnlyX HOT 5
- registerHandler before a watchX causes a crash HOT 5
- getItMixin web support HOT 9
- `Watch` does not trigger rebuild HOT 13
- registerStreamHandler causes unnecessary re-renders HOT 1
- Operand of null-aware operation '!' has type ... which excludes null HOT 4
- Error using pushScope HOT 5
- error in readme HOT 1
- Not able to recognize the return types. " The return type 'void' isn't a 'ValueListenable<R>', as required by the closure's context." HOT 2
- Using the watch calls on specific GetIt instance? HOT 7
- Put full license text in LICENSE file
- Question Regarding Example in Readme HOT 1
- How to use registerHandler for same subsequent calls ? HOT 2
- Watch list value changes don't trigger rebuild HOT 1
- Does this support restoration stuff like hydrated_bloc package? HOT 1
- Possible syntax simplification - type inference HOT 1
- Couldn't make it work for me HOT 1
- Switch to my new Package watch_it HOT 2
- Missing tag on GitHub HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from get_it_mixin.