Skip to content

Commit 643e12d

Browse files
docs(all): improve documentation across multiple README files (#3630)
Co-authored-by: Volodymyr Buberenko <[email protected]>
1 parent 9597aab commit 643e12d

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

packages/android_alarm_manager_plus/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ This intent has the action `android.intent.action.MAIN` and includes the followi
113113
Setting the alarm:
114114

115115
```dart
116+
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
117+
116118
await AndroidAlarmManager.oneShotAt(
117119
time,
118120
id,

packages/android_intent_plus/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ of integers or strings.
8888
or get the details of the activity that can handle the intent.
8989

9090
```dart
91+
import 'package:android_intent_plus/android_intent.dart';
92+
9193
final intent = AndroidIntent(
9294
action: 'action_view',
9395
data: Uri.encodeFull('http://'),

packages/connectivity_plus/connectivity_plus/README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,31 @@ This method should ensure emitting only distinct values.
7171

7272
```dart
7373
import 'package:connectivity_plus/connectivity_plus.dart';
74+
import 'dart:async';
7475
75-
@override
76-
initState() {
77-
super.initState();
78-
79-
StreamSubscription<List<ConnectivityResult>> subscription = Connectivity().onConnectivityChanged.listen((List<ConnectivityResult> result) {
80-
// Received changes in available connectivity types!
81-
});
76+
class MyWidget extends StatefulWidget {
77+
@override
78+
_MyWidgetState createState() => _MyWidgetState();
8279
}
8380
84-
// Be sure to cancel subscription after you are done
85-
@override
86-
dispose() {
87-
subscription.cancel();
88-
super.dispose();
81+
class _MyWidgetState extends State<MyWidget> {
82+
StreamSubscription<List<ConnectivityResult>>? subscription;
83+
84+
@override
85+
void initState() {
86+
super.initState();
87+
88+
subscription = Connectivity().onConnectivityChanged.listen((List<ConnectivityResult> result) {
89+
// Received changes in available connectivity types!
90+
});
91+
}
92+
93+
// Be sure to cancel subscription after you are done
94+
@override
95+
void dispose() {
96+
subscription?.cancel();
97+
super.dispose();
98+
}
8999
}
90100
```
91101

packages/sensors_plus/sensors_plus/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ Alternatively, every stream allows to specify the sampling rate for its sensor u
153153
154154

155155
```dart
156+
import 'package:sensors_plus/sensors_plus.dart';
157+
156158
magnetometerEvents(samplingPeriod: SensorInterval.normalInterval).listen(
157159
(MagnetometerEvent event) {
158160
print(event);

packages/share_plus/share_plus/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Access the `SharePlus` instance via `SharePlus.instance`.
5151
Then, invoke the `share()` method anywhere in your Dart code.
5252

5353
```dart
54+
import 'package:share_plus/share_plus.dart';
55+
5456
SharePlus.instance.share(
5557
ShareParams(text: 'check out my website https://example.com')
5658
);
@@ -83,6 +85,9 @@ To share one or multiple files, provide the `files` list in `ShareParams`.
8385
Optionally, you can pass `title`, `text` and `sharePositionOrigin`.
8486

8587
```dart
88+
import 'package:share_plus/share_plus.dart';
89+
import 'package:cross_file/cross_file.dart';
90+
8691
final params = ShareParams(
8792
text: 'Great picture',
8893
files: [XFile('${directory.path}/image.jpg')],
@@ -96,6 +101,9 @@ if (result.status == ShareResultStatus.success) {
96101
```
97102

98103
```dart
104+
import 'package:share_plus/share_plus.dart';
105+
import 'package:cross_file/cross_file.dart';
106+
99107
final params = ShareParams(
100108
files: [
101109
XFile('${directory.path}/image1.jpg'),
@@ -119,6 +127,8 @@ package.
119127
File downloading fallback mechanism for web can be disabled by setting:
120128

121129
```dart
130+
import 'package:share_plus/share_plus.dart';
131+
122132
ShareParams(
123133
// rest of params
124134
downloadFallbackEnabled: false,
@@ -132,6 +142,10 @@ You can also share files that you dynamically generate from its data using [`XFi
132142
To set the name of such files, use the `fileNameOverrides` parameter, otherwise the file name will be a random UUID string.
133143

134144
```dart
145+
import 'package:share_plus/share_plus.dart';
146+
import 'package:cross_file/cross_file.dart';
147+
import 'dart:convert';
148+
135149
final params = ShareParams(
136150
files: [XFile.fromData(utf8.encode(text), mimeType: 'text/plain')],
137151
fileNameOverrides: ['myfile.txt']
@@ -150,6 +164,8 @@ This special functionality is only properly supported on iOS.
150164
On other platforms, the URI will be shared as plain text.
151165

152166
```dart
167+
import 'package:share_plus/share_plus.dart';
168+
153169
final params = ShareParams(uri: uri);
154170
155171
SharePlus.instance.share(params);
@@ -233,7 +249,7 @@ or search for other Flutter plugins implementing this SDK. More information can
233249
Other apps may also give problems when attempting to share content to them.
234250
This is because 3rd party app developers do not properly implement the logic to receive share actions.
235251

236-
We cannot warranty that a 3rd party app will properly implement the share functionality.
252+
We cannot guarantee that a 3rd party app will properly implement the share functionality.
237253
Therefore, **all bugs reported regarding compatibility with a specific app will be closed.**
238254

239255
#### Localization in Apple platforms
@@ -249,7 +265,7 @@ For more information check the [CoreFoundationKeys](https://developer.apple.com/
249265
`share_plus` requires iPad users to provide the `sharePositionOrigin` parameter.
250266

251267
Without it, `share_plus` will not work on iPads and may cause a crash or
252-
letting the UI not responding.
268+
leave the UI unresponsive.
253269

254270
To avoid that problem, provide the `sharePositionOrigin`.
255271

@@ -292,6 +308,8 @@ To convert code using `Share.share()` to the new `SharePlus` class:
292308
e.g.
293309

294310
```dart
311+
import 'package:share/share.dart';
312+
295313
Share.share("Shared text");
296314
297315
Share.shareUri("http://example.com");
@@ -302,6 +320,8 @@ Share.shareXFiles(files);
302320
Becomes:
303321

304322
```dart
323+
import 'package:share_plus/share_plus.dart';
324+
305325
SharePlus.instance.share(
306326
ShareParams(text: "Shared text"),
307327
);

0 commit comments

Comments
 (0)