Skip to content

Commit

Permalink
feat: ✨ adds autolink and nullsafety
Browse files Browse the repository at this point in the history
Null Safety
  • Loading branch information
CodingAleCR committed Jun 6, 2021
1 parent d55f975 commit cfc371c
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 66 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
# WidgetKit

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

## List of widgets
## List of Widgets

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

### Shared

#### HideKeyboardOnTouchOutside

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.

#### AutolinkText

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).

### Material

#### Password TextField

A widget that allows you to show or hide the password already embedded.
A widget that allows you to show or hide the password already embedded.

### Cupertino

#### Coming Soon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 63 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ void main() {
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Widgetkit Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
primarySwatch: Colors.blueGrey,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: MyHomePage(title: 'Widgetkit Demo'),
);
}
}
Expand All @@ -42,17 +41,76 @@ class _MyHomePageState extends State<MyHomePage> {
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
Text(
"PasswordTextField",
style: Theme.of(context).textTheme.headline6,
),
SizedBox(height: 16),
PasswordTextField(),
SizedBox(height: 16),
PasswordTextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
SizedBox(height: 32),
Text(
"CupertinoPasswordTextField",
style: Theme.of(context).textTheme.headline6,
),
SizedBox(height: 16),
CupertinoTextField(
obscureText: true,
suffix: Icon(CupertinoIcons.eye),
suffix: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Icon(CupertinoIcons.eye),
),
),
SizedBox(height: 32),
Text(
"AutolinkText",
style: Theme.of(context).textTheme.headline6,
),
SizedBox(height: 16),
AutolinkText(
"Hello world from https://www.flutter.dev/",
textStyle: TextStyle(color: Colors.black),
linkStyle: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
),
onWebLinkTap: (String url) => print(url),
),
SizedBox(height: 16),
AutolinkText(
"Humanized (removes scheme) https://www.flutter.dev/",
humanize: true,
textStyle: TextStyle(color: Colors.black),
linkStyle: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
),
onWebLinkTap: (String url) => print(url),
),
SizedBox(height: 16),
AutolinkText(
"Autolink email [email protected]",
textStyle: TextStyle(color: Colors.black),
linkStyle: TextStyle(
color: Colors.green,
decoration: TextDecoration.underline,
),
onEmailTap: (String url) => print(url),
),
SizedBox(height: 16),
AutolinkText(
"Autolink phone +50688884444",
textStyle: TextStyle(color: Colors.black),
linkStyle: TextStyle(
color: Colors.orange,
decoration: TextDecoration.underline,
),
onPhoneTap: (String url) => print(url),
),
],
),
Expand Down
42 changes: 21 additions & 21 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,21 +73,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -99,63 +99,63 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
widgetkit:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.2.0"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.17.0 <2.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
18 changes: 9 additions & 9 deletions lib/material/password_textfield.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';

class PasswordTextField extends StatefulWidget {
final Key key;
final TextEditingController controller;
final InputDecoration decoration;
final Function(String) validator;
final bool enabled;
final AutovalidateMode autovalidateMode;
final Key? key;
final TextEditingController? controller;
final InputDecoration? decoration;
final String? Function(String?)? validator;
final bool? enabled;
final AutovalidateMode? autovalidateMode;
final bool autocorrect;
final void Function(String) onChanged;
final void Function(String)? onChanged;

PasswordTextField({
this.key,
Expand All @@ -26,7 +26,7 @@ class PasswordTextField extends StatefulWidget {
}

class _PasswordTextFieldState extends State<PasswordTextField> {
bool _passwordHidden;
late bool _passwordHidden;

@override
void initState() {
Expand Down Expand Up @@ -67,7 +67,7 @@ class _PasswordTextFieldState extends State<PasswordTextField> {
),
);
} else {
decoration = widget.decoration.copyWith(
decoration = widget.decoration!.copyWith(
suffixIcon: IconButton(
icon: Icon(
_passwordHidden ? Icons.visibility : Icons.visibility_off,
Expand Down
Loading

0 comments on commit cfc371c

Please sign in to comment.