Skip to content

Commit a767267

Browse files
committed
fix stracture
1 parent a1e3271 commit a767267

File tree

7 files changed

+247
-26
lines changed

7 files changed

+247
-26
lines changed

.idea/common_utilities.iml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Dart_Packages.xml

Lines changed: 212 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/main.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import 'package:common_utilities/common_utilities.dart';
22

33
void main() {
4-
String mainStr =
5-
'If you want something you have never had you must do something you have never done';
4+
String yourStr = 'If you want something you have never had you must do something you have never done';
65

7-
String result = mainStr.stringUtils().subStringBetween('want', 'never');
8-
// prints => 'something you have'
6+
String result = yourStr.stringUtils().subStringBetween('want', 'never');
7+
// print(result) => 'something you have'
98

10-
List<String> result2 =
11-
mainStr.stringUtils().subStringsBetween('you', 'never');
12-
// prints => ['something you have' , 'must do something you have']
9+
List<String> result2 = yourStr.stringUtils().subStringsBetween('you', 'never');
10+
// print(result2) => ['something you have' , 'must do something you have']
1311

14-
String result3 = mainStr.stringUtils().subStringAfter('something');
15-
// prints => 'you have never had you must do something you have never done'
12+
String result3 = yourStr.stringUtils().subStringAfter('something');
13+
// print(result3) => 'you have never had you must do something you have never done'
1614

1715
bool lastIndex = true; //This is optional & its false by default
18-
String result4 = mainStr.stringUtils().subStringAfter('something', lastIndex);
19-
// prints => 'you have never done'
16+
String result4 = yourStr.stringUtils().subStringAfter('something', lastIndex);
17+
// print(result4) => 'you have never done'
18+
19+
String str = CommonUtils.getRandomString(10);
20+
// print(str) => 'btorklcvxw'
21+
2022
}

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: example
2-
description: A new Flutter project.
2+
description: example to show how to use common_utilities library
33
publish_to: none
44
version: 1.0.0+1
55

lib/common_utilities.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
library common_utilities;
22

33
export 'src/extensions.dart';
4-
export 'src/static_methods.dart';
4+
export 'src/common_utils.dart';

lib/src/common_utils.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import 'dart:convert';
2+
import 'dart:math';
3+
4+
class CommonUtils {
5+
6+
/// generate a secure random string
7+
static String getRandomString(int len) {
8+
var random = Random.secure();
9+
var values = List<int>.generate(len, (i) => random.nextInt(255));
10+
return base64UrlEncode(values);
11+
}
12+
13+
14+
15+
16+
}

lib/src/static_methods.dart

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)