Skip to content

Commit 545b40c

Browse files
authored
docs: enhancement (#15)
1 parent 1e1b148 commit 545b40c

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

docs/src/content/docs/examples/basic.mdx

-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ In particular, it shows how to create a provider, how to scope it, how to use it
1313
import 'package:disco/disco.dart';
1414
import 'package:flutter/material.dart';
1515
16-
/// ---
17-
/// Model
18-
/// ---
1916
abstract class Model extends ChangeNotifier {
2017
void incrementCounter();
2118
@@ -35,9 +32,6 @@ class ModelImplementation extends Model {
3532
}
3633
}
3734
38-
/// ---
39-
/// Provider
40-
/// ---
4135
final modelProvider = Provider<Model>((context) => ModelImplementation());
4236
4337
void main() {

docs/src/content/docs/index.mdx

+24
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ description: Official documentation for Disco, a modern and simple library for s
77

88
Disco is a library introducing a new concept of providers that operate differently from those already present in the Flutter ecosystem. It was developed to overcome the challenges and limitations in the context of dependency injection.
99

10+
## Usage
11+
12+
### Creating a provider
13+
14+
```dart
15+
final modelProvider = Provider((context) => Model());
16+
```
17+
18+
### Providing a provider
19+
20+
```dart
21+
ProviderScope(
22+
providers: [modelProvider],
23+
child: MyWidget(),
24+
)
25+
```
26+
27+
### Retrieving a provider
28+
```dart
29+
final model = modelProvider.of(context);
30+
```
31+
32+
You can retrieve a provider from any widget in the subtree of the `ProviderScope` where the provider has been provided.
33+
1034
To get straight to the point, pros and cons are summarized below.
1135

1236
### Pros

0 commit comments

Comments
 (0)