Skip to content

Commit

Permalink
chore: remove solid signal (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
nank1ro authored Oct 29, 2023
1 parent adc64cb commit 5c08932
Show file tree
Hide file tree
Showing 45 changed files with 225 additions and 379 deletions.
2 changes: 1 addition & 1 deletion docs/examples/github-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class SearchPage extends StatelessWidget {
Widget build(BuildContext context) {
return Solid(
providers: [
SolidProvider<GithubSearchBloc>(
Provider<GithubSearchBloc>(
create: () => GithubSearchBloc(),
dispose: (bloc) => bloc.dispose(),
),
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/todos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class TodosPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Using SolidProvider here to provide the [TodosController] to descendants.
// Using Provider here to provide the [TodosController] to descendants.
return Solid(
providers: [
SolidProvider<TodosController>(
Provider<TodosController>(
create: () => TodosController(initialTodos: Todo.sample),
dispose: (controller) => controller.dispose(),
),
Expand Down Expand Up @@ -484,10 +484,10 @@ class TodosPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Using SolidProvider here to provide the [TodosController] to descendants.
// Using Provider here to provide the [TodosController] to descendants.
return Solid(
providers: [
SolidProvider<TodosController>(
Provider<TodosController>(
create: () => TodosController(initialTodos: Todo.sample),
dispose: (controller) => controller.dispose(),
),
Expand Down Expand Up @@ -529,7 +529,7 @@ Widget wrapWithMockedTodosController({
return MaterialApp(
home: Solid(
providers: [
SolidProvider<TodosController>(
Provider<TodosController>(
create: () => todosController,
dispose: (controller) => controller.dispose(),
),
Expand Down
14 changes: 7 additions & 7 deletions docs/flutter/solid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The `context.get()` method doesn't listen to the signal value. You may use this

## Providers

You can also pass `SolidProvider`s to descendants:
You can also pass `Provider`s to descendants:

```dart
class NameProvider {
Expand All @@ -121,29 +121,29 @@ class NumberProvider {
final int number;
}
class SolidProvidersPage extends StatelessWidget {
const SolidProvidersPage({super.key});
class ProvidersPage extends StatelessWidget {
const ProvidersPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('SolidProviders'),
title: const Text('Providers'),
),
body: Solid(
providers: [
SolidProvider<NameProvider>(
Provider<NameProvider>(
create: () => const NameProvider('Ale'),
// the dispose method is fired when the [Solid] widget above is removed from the widget tree.
dispose: (provider) => provider.dispose(),
),
SolidProvider<NumberProvider>(
Provider<NumberProvider>(
create: () => const NumberProvider(1),
// Do not create the provider lazily, but immediately
lazy: false,
id: 1,
),
SolidProvider<NumberProvider>(
Provider<NumberProvider>(
create: () => const NumberProvider(10),
id: 2,
),
Expand Down
66 changes: 4 additions & 62 deletions docs/lints/lints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ description: All the lints provided by solidart_lint

# Lints

### avoid_dynamic_solid_provider
### avoid_dynamic_provider

`SolidProvider` cannot be dynamic
`Provider` cannot be dynamic

**Bad**:

```dart
Solid(
providers: [
SolidProvider(create: () => MyClass()),
Provider(create: () => MyClass()),
],
),
```
Expand All @@ -24,69 +24,11 @@ Solid(
```dart
Solid(
providers: [
SolidProvider<MyClass>(create: () => MyClass()),
Provider<MyClass>(create: () => MyClass()),
],
),
```

### avoid_dynamic_solid_signal

Solid `signals` cannot be dynamic

**Bad**:

```dart
Solid(
signals: {
'id': () => createSignal(0),
},
),
```

**Good**:

```dart
Solid(
signals: {
'id': () => createSignal<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**:

```dart
final provider = context.get<Signal<MyClass>>();
```

**Good**:

```dart
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**:

```dart
final signal = context.get<MyClass>('signal-id');
```

**Good**:

```dart
final signal = context.get<Signal<int>>('signal-id');
```

### invalid_solid_get_type

Specify the provider or signal type you want to get.
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_solidart: ^1.1.0
flutter_solidart: ^1.4.0

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
2 changes: 1 addition & 1 deletion examples/github_search/lib/ui/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SearchPage extends StatelessWidget {
return Solid(
providers: [
// Provide the [GithubSearchBloc] to descendants
SolidProvider<GithubSearchBloc>(
Provider<GithubSearchBloc>(
create: () => GithubSearchBloc(),
dispose: (bloc) => bloc.dispose(),
),
Expand Down
2 changes: 1 addition & 1 deletion examples/github_search/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_solidart: ^1.1.0
flutter_solidart: ^1.4.0
json_annotation: ^4.8.1
equatable: ^2.0.5
http: ^1.0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/todos/lib/todos_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class TodosPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
// Using SolidProvider here to provide the [TodosController] to descendants.
// Using Provider here to provide the [TodosController] to descendants.
return Solid(
providers: [
SolidProvider<TodosController>(
Provider<TodosController>(
create: () => TodosController(initialTodos: Todo.sample),
dispose: (controller) => controller.dispose(),
),
Expand Down
2 changes: 1 addition & 1 deletion examples/todos/lib/widgets/todos_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _TodosBodyState extends State<TodosBody> {
providers: [
// make the active filter signal visible only to descendants.
// created here because this is where it starts to be necessary.
SolidSignal<Signal<TodosFilter>>(create: () => Signal(TodosFilter.all)),
Provider<Signal<TodosFilter>>(create: () => Signal(TodosFilter.all)),
],
child: Column(
children: [
Expand Down
2 changes: 1 addition & 1 deletion examples/todos/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_solidart: ^1.1.0
flutter_solidart: ^1.4.0

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
2 changes: 1 addition & 1 deletion examples/todos/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Widget wrapWithMockedTodosController({
return MaterialApp(
home: Solid(
providers: [
SolidProvider<TodosController>(
Provider<TodosController>(
create: () => todosController,
dispose: (controller) => controller.dispose(),
),
Expand Down
2 changes: 1 addition & 1 deletion examples/toggle_theme/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MyApp extends StatelessWidget {
// Provide the theme mode signal to descendats
return Solid(
providers: [
SolidSignal<Signal<ThemeMode>>(
Provider<Signal<ThemeMode>>(
create: () => Signal(ThemeMode.light),
),
],
Expand Down
2 changes: 1 addition & 1 deletion examples/toggle_theme/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_solidart: ^1.1.0
flutter_solidart: ^1.4.0

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
5 changes: 5 additions & 0 deletions packages/flutter_solidart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.4.0

- **CHORE**: Rename `SolidProvider` into `Provider`.
- **REFACTOR**: Remove `SolidSignal` in favor of `Provider`.

## 1.3.0

### Changes from solidart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class MultipleSignalsPage extends StatelessWidget {
body: Solid(
providers: [
// provide the firstName signal to descendants
SolidSignal<Signal<String>>(
Provider<Signal<String>>(
create: () => Signal("James"),
id: #firstName,
),

// provide the lastName signal to descendants
SolidSignal<Signal<String>>(
Provider<Signal<String>>(
create: () => Signal("Smith"),
id: #lastName,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ObserveSignalPage extends StatelessWidget {
body: Solid(
providers: [
// provide the count signal to descendants
SolidSignal<Signal<int>>(create: () => Signal(0)),
Provider<Signal<int>>(create: () => Signal(0)),
],
child: const SomeChild(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'observe_signal_page.dart';

final _pages = {
'Solid Providers': () => const SolidProvidersPage(),
'Solid Providers': () => const ProvidersPage(),
'Solid Signals': () => const SolidSignalsPage(),
'Observe Signal': () => const ObserveSignalPage(),
'Multiple Signals': () => const MultipleSignalsPage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ class NumberProvider {
final int number;
}

class SolidProvidersPage extends StatelessWidget {
const SolidProvidersPage({super.key});
class ProvidersPage extends StatelessWidget {
const ProvidersPage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Solid Providers'),
title: const Text('Providers'),
),
body: Solid(
providers: [
SolidProvider<NameProvider>(
Provider<NameProvider>(
create: () => const NameProvider('Ale'),
// the dispose method is fired when the [Solid] widget above is removed from the widget tree.
dispose: (provider) => provider.dispose(),
),
SolidProvider<NumberProvider>(
Provider<NumberProvider>(
create: () => const NumberProvider(1),
// Do not create the provider lazily, but immediately
lazy: false,
id: #firstNumber,
),
SolidProvider<NumberProvider>(
Provider<NumberProvider>(
create: () => const NumberProvider(100),
// Do not create the provider lazily, but immediately
lazy: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class _SolidReactivityPageState extends State<SolidReactivityPage> {
Widget build(BuildContext context) {
return Solid(
providers: [
SolidSignal<Signal<int>>(create: () => Signal(0), id: #firstCounter),
SolidSignal<Signal<int>>(create: () => Signal(0), id: #secondCounter),
Provider<Signal<int>>(create: () => Signal(0), id: #firstCounter),
Provider<Signal<int>>(create: () => Signal(0), id: #secondCounter),
],
child: Scaffold(
appBar: AppBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class _SolidSignalsPageState extends State<SolidSignalsPage> {
body: Solid(
providers: [
// provide the count signal to descendants
SolidSignal<Signal<int>>(
Provider<Signal<int>>(
create: () => count,
// do not autoDispose the signal, because we already dispose it ourself
autoDispose: false,
),

// provide the doubleCount signal to descendants
SolidSignal<Computed<int>>(
Provider<Computed<int>>(
create: () => Computed(() => count() * 2),
),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_solidart/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flutter_solidart: ^1.1.0
flutter_solidart: ^1.4.0

dev_dependencies:
flutter_test:
Expand Down
Loading

0 comments on commit 5c08932

Please sign in to comment.