Skip to content

Commit cfc371c

Browse files
committed
feat: ✨ adds autolink and nullsafety
Null Safety
1 parent d55f975 commit cfc371c

File tree

10 files changed

+316
-66
lines changed

10 files changed

+316
-66
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# WidgetKit
22

3-
A kit of widgets that are (almost) always needed in the different apps.
3+
A kit of widgets that are (almost) always needed in the different Flutter apps.
44

5-
## List of widgets
5+
## List of Widgets
66

7-
- Shared: Widgets that can be used globally, regardless of which app you are based off(Material or Cupertino).
8-
- Material: Widgets for MaterialApp based apps or for the Material look and feel.
9-
- (WIP)Cupertino: Widgets for CupertinoApp based apps or for the Cupertino(iOS) look and feel.
7+
- [Shared](#shared): Widgets that can be used globally, regardless of which app you are based off(Material or Cupertino).
8+
- [Material](#material): Widgets for MaterialApp based apps or for the Material look and feel.
9+
- [Cupertino](#cupertino) **(Coming Soon!)**: Widgets for CupertinoApp based apps or for the Cupertino(iOS) look and feel.
1010

1111
### Shared
1212

1313
#### HideKeyboardOnTouchOutside
1414

1515
A widget that you can use to wrap other widgets (like a Scaffold or a Form) that usually contain inputs, this will help hide the keyboard when touching outside.
1616

17+
#### AutolinkText
18+
19+
A text widget, that turns URLs, email and phone numbers into clickable inline links in text for flutter. A null safe version of FogNature's [AutolinkText](https://github.com/FogNature/flutter_autolink_text).
20+
1721
### Material
1822

1923
#### Password TextField
2024

21-
A widget that allows you to show or hide the password already embedded.
25+
A widget that allows you to show or hide the password already embedded.
26+
27+
### Cupertino
28+
29+
#### Coming Soon

example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/main.dart

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ void main() {
77
}
88

99
class MyApp extends StatelessWidget {
10-
// This widget is the root of your application.
1110
@override
1211
Widget build(BuildContext context) {
1312
return MaterialApp(
14-
title: 'Flutter Demo',
13+
title: 'Widgetkit Demo',
1514
theme: ThemeData(
16-
primarySwatch: Colors.blue,
15+
primarySwatch: Colors.blueGrey,
1716
visualDensity: VisualDensity.adaptivePlatformDensity,
1817
),
19-
home: MyHomePage(title: 'Flutter Demo Home Page'),
18+
home: MyHomePage(title: 'Widgetkit Demo'),
2019
);
2120
}
2221
}
@@ -42,17 +41,76 @@ class _MyHomePageState extends State<MyHomePage> {
4241
padding: const EdgeInsets.all(8.0),
4342
child: ListView(
4443
children: [
44+
Text(
45+
"PasswordTextField",
46+
style: Theme.of(context).textTheme.headline6,
47+
),
48+
SizedBox(height: 16),
4549
PasswordTextField(),
4650
SizedBox(height: 16),
4751
PasswordTextField(
4852
decoration: InputDecoration(
4953
border: OutlineInputBorder(),
5054
),
5155
),
56+
SizedBox(height: 32),
57+
Text(
58+
"CupertinoPasswordTextField",
59+
style: Theme.of(context).textTheme.headline6,
60+
),
5261
SizedBox(height: 16),
5362
CupertinoTextField(
5463
obscureText: true,
55-
suffix: Icon(CupertinoIcons.eye),
64+
suffix: Padding(
65+
padding: const EdgeInsets.symmetric(horizontal: 8),
66+
child: Icon(CupertinoIcons.eye),
67+
),
68+
),
69+
SizedBox(height: 32),
70+
Text(
71+
"AutolinkText",
72+
style: Theme.of(context).textTheme.headline6,
73+
),
74+
SizedBox(height: 16),
75+
AutolinkText(
76+
"Hello world from https://www.flutter.dev/",
77+
textStyle: TextStyle(color: Colors.black),
78+
linkStyle: TextStyle(
79+
color: Colors.blue,
80+
decoration: TextDecoration.underline,
81+
),
82+
onWebLinkTap: (String url) => print(url),
83+
),
84+
SizedBox(height: 16),
85+
AutolinkText(
86+
"Humanized (removes scheme) https://www.flutter.dev/",
87+
humanize: true,
88+
textStyle: TextStyle(color: Colors.black),
89+
linkStyle: TextStyle(
90+
color: Colors.blue,
91+
decoration: TextDecoration.underline,
92+
),
93+
onWebLinkTap: (String url) => print(url),
94+
),
95+
SizedBox(height: 16),
96+
AutolinkText(
97+
"Autolink email [email protected]",
98+
textStyle: TextStyle(color: Colors.black),
99+
linkStyle: TextStyle(
100+
color: Colors.green,
101+
decoration: TextDecoration.underline,
102+
),
103+
onEmailTap: (String url) => print(url),
104+
),
105+
SizedBox(height: 16),
106+
AutolinkText(
107+
"Autolink phone +50688884444",
108+
textStyle: TextStyle(color: Colors.black),
109+
linkStyle: TextStyle(
110+
color: Colors.orange,
111+
decoration: TextDecoration.underline,
112+
),
113+
onPhoneTap: (String url) => print(url),
56114
),
57115
],
58116
),

example/pubspec.lock

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.5.0-nullsafety.1"
10+
version: "2.5.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.1.0-nullsafety.1"
17+
version: "2.1.0"
1818
characters:
1919
dependency: transitive
2020
description:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0-nullsafety.3"
24+
version: "1.1.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0-nullsafety.1"
31+
version: "1.2.0"
3232
clock:
3333
dependency: transitive
3434
description:
3535
name: clock
3636
url: "https://pub.dartlang.org"
3737
source: hosted
38-
version: "1.1.0-nullsafety.1"
38+
version: "1.1.0"
3939
collection:
4040
dependency: transitive
4141
description:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0-nullsafety.3"
45+
version: "1.15.0"
4646
cupertino_icons:
4747
dependency: "direct main"
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: fake_async
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "1.2.0-nullsafety.1"
59+
version: "1.2.0"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -73,21 +73,21 @@ packages:
7373
name: matcher
7474
url: "https://pub.dartlang.org"
7575
source: hosted
76-
version: "0.12.10-nullsafety.1"
76+
version: "0.12.10"
7777
meta:
7878
dependency: transitive
7979
description:
8080
name: meta
8181
url: "https://pub.dartlang.org"
8282
source: hosted
83-
version: "1.3.0-nullsafety.3"
83+
version: "1.3.0"
8484
path:
8585
dependency: transitive
8686
description:
8787
name: path
8888
url: "https://pub.dartlang.org"
8989
source: hosted
90-
version: "1.8.0-nullsafety.1"
90+
version: "1.8.0"
9191
sky_engine:
9292
dependency: transitive
9393
description: flutter
@@ -99,63 +99,63 @@ packages:
9999
name: source_span
100100
url: "https://pub.dartlang.org"
101101
source: hosted
102-
version: "1.8.0-nullsafety.2"
102+
version: "1.8.0"
103103
stack_trace:
104104
dependency: transitive
105105
description:
106106
name: stack_trace
107107
url: "https://pub.dartlang.org"
108108
source: hosted
109-
version: "1.10.0-nullsafety.1"
109+
version: "1.10.0"
110110
stream_channel:
111111
dependency: transitive
112112
description:
113113
name: stream_channel
114114
url: "https://pub.dartlang.org"
115115
source: hosted
116-
version: "2.1.0-nullsafety.1"
116+
version: "2.1.0"
117117
string_scanner:
118118
dependency: transitive
119119
description:
120120
name: string_scanner
121121
url: "https://pub.dartlang.org"
122122
source: hosted
123-
version: "1.1.0-nullsafety.1"
123+
version: "1.1.0"
124124
term_glyph:
125125
dependency: transitive
126126
description:
127127
name: term_glyph
128128
url: "https://pub.dartlang.org"
129129
source: hosted
130-
version: "1.2.0-nullsafety.1"
130+
version: "1.2.0"
131131
test_api:
132132
dependency: transitive
133133
description:
134134
name: test_api
135135
url: "https://pub.dartlang.org"
136136
source: hosted
137-
version: "0.2.19-nullsafety.2"
137+
version: "0.2.19"
138138
typed_data:
139139
dependency: transitive
140140
description:
141141
name: typed_data
142142
url: "https://pub.dartlang.org"
143143
source: hosted
144-
version: "1.3.0-nullsafety.3"
144+
version: "1.3.0"
145145
vector_math:
146146
dependency: transitive
147147
description:
148148
name: vector_math
149149
url: "https://pub.dartlang.org"
150150
source: hosted
151-
version: "2.1.0-nullsafety.3"
151+
version: "2.1.0"
152152
widgetkit:
153153
dependency: "direct main"
154154
description:
155155
path: ".."
156156
relative: true
157157
source: path
158-
version: "0.0.1"
158+
version: "0.2.0"
159159
sdks:
160-
dart: ">=2.10.0-110 <2.11.0"
161-
flutter: ">=1.17.0 <2.0.0"
160+
dart: ">=2.12.0 <3.0.0"
161+
flutter: ">=1.17.0"

lib/material/password_textfield.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import 'package:flutter/material.dart';
22

33
class PasswordTextField extends StatefulWidget {
4-
final Key key;
5-
final TextEditingController controller;
6-
final InputDecoration decoration;
7-
final Function(String) validator;
8-
final bool enabled;
9-
final AutovalidateMode autovalidateMode;
4+
final Key? key;
5+
final TextEditingController? controller;
6+
final InputDecoration? decoration;
7+
final String? Function(String?)? validator;
8+
final bool? enabled;
9+
final AutovalidateMode? autovalidateMode;
1010
final bool autocorrect;
11-
final void Function(String) onChanged;
11+
final void Function(String)? onChanged;
1212

1313
PasswordTextField({
1414
this.key,
@@ -26,7 +26,7 @@ class PasswordTextField extends StatefulWidget {
2626
}
2727

2828
class _PasswordTextFieldState extends State<PasswordTextField> {
29-
bool _passwordHidden;
29+
late bool _passwordHidden;
3030

3131
@override
3232
void initState() {
@@ -67,7 +67,7 @@ class _PasswordTextFieldState extends State<PasswordTextField> {
6767
),
6868
);
6969
} else {
70-
decoration = widget.decoration.copyWith(
70+
decoration = widget.decoration!.copyWith(
7171
suffixIcon: IconButton(
7272
icon: Icon(
7373
_passwordHidden ? Icons.visibility : Icons.visibility_off,

0 commit comments

Comments
 (0)