This package is a developer tool for users of flutter_solidart, designed to help stop common issues and simplify repetitive tasks.
I highly recommend using this package to avoid errors and understand how to properly use flutter_solidart
Getting started
Run this command in the root of your Flutter project:
flutter pub add -d solidart_lint custom_lint
Then edit your analysis_options.yaml
file and add these lines of code:
analyzer:
plugins:
- custom_lint
Then run:
flutter clean
flutter pub get
dart run custom_lint
ASSISTS
Wrap with Solid
Wrap with SignalBuilder
Wrap with ResourceBuilder
Wrap with Show
LINTS
avoid_dynamic_solid_provider
Provider
cannot be dynamic
Bad:
Solid(
providers: [
Provider(create: () => MyClass()),
],
),
Good:
Solid(
providers: [
Provider<MyClass>(create: () => MyClass()),
],
),
avoid_dynamic_solid_signal
Solid signals
cannot be dynamic
Bad:
Solid(
signals: {
'id': () => Signal(0),
},
),
Good:
Solid(
signals: {
'id': () => Signal<int>(0),
},
),
invalid_provider_type
The provider type you want to retrieve is invalid, must not implement SignalBase
.
You cannot retrieve a provider that implements SignalBase
, like Signal
, ReadSignal
and Resource
.
Bad:
final provider = context.get<Signal<MyClass>>();
Good:
final provider = context.get<MyClass>();
invalid_signal_type
The signal type you want to retrieve is invalid, must implement SignalBase
.
You can retrieve signals that implement SignalBase
, like Signal
, ReadSignal
and Resource
.
Bad:
final signal = context.get<MyClass>('signal-id');
Good:
final signal = context.get<Signal<int>>('signal-id');
invalid_solid_get_type
Specify the provider or signal type you want to get.
Bad:
final provider = context.get();
Good:
final provider = context.get<MyClass>();
invalid_observe_type
The type you want to observe is invalid, must not implement SignalBase
.
You cannot observe a signal that implements SignalBase
, like Signal
, ReadSignal
and Resource
.
Bad:
final counter = context.observe<Signal<int>>('counter');
Good:
final counter = context.observe<int>('counter');
invalid_update_type
The update type is invalid, must not implement SignalBase
.
You cannot update a signal that implements SignalBase
, like Signal
, ReadSignal
and Resource
.
Bad:
context.update<Signal<int>>('counter', (value) => value * 2);
Good:
context.update<int>('counter', (value) => value * 2);
Libraries
- solidart_lint
- Support for doing something awesome.