Skip to content

Commit

Permalink
feat: support null-safety
Browse files Browse the repository at this point in the history
Closes: #1
  • Loading branch information
JonasWanke committed Feb 25, 2021
1 parent e987085 commit 1dc1f04
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 418 deletions.
78 changes: 39 additions & 39 deletions example/lib/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class ButtonsExample extends StatelessWidget {
Text('isLoading: true'),
]),
_buildSpacerRow(),
_buildFancyFlatButtonRow(),
_buildFancyTextButtonRow(),
_buildSpacerRow(),
_buildFancyIconFlatButtonRow(),
_buildSpacerRow(),
_buildFancyOutlineButtonRow(),
_buildFancyOutlinedButtonRow(),
_buildSpacerRow(),
_buildFancyIconOutlineButtonRow(),
_buildSpacerRow(),
_buildFancyRaisedButtonRow(),
_buildFancyElevatedButtonRow(),
_buildSpacerRow(),
_buildFancyIconRaisedButtonRow(),
_buildSpacerRow(),
Expand All @@ -49,56 +49,56 @@ class ButtonsExample extends StatelessWidget {
);
}

TableRow _buildFancyFlatButtonRow() => _buildRow('FancyFlatButton', [
FancyFlatButton(
TableRow _buildFancyTextButtonRow() => _buildRow('FancyTextButton', [
FancyTextButton(
onPressed: () {},
child: Text('child'),
),
FancyFlatButton(
FancyTextButton(
onPressed: null,
child: Text('child'),
),
FancyFlatButton(
FancyTextButton(
isEnabled: false,
onPressed: () {},
child: Text('child'),
),
FancyFlatButton(
FancyTextButton(
onPressed: () {},
isLoading: true,
child: Text('child'),
),
FancyFlatButton(
FancyTextButton(
onPressed: () {},
isLoading: true,
loadingChild: Text('loadingChild'),
child: Text('child'),
),
]);
TableRow _buildFancyIconFlatButtonRow() => _buildRow('FancyFlatButton.icon', [
FancyFlatButton.icon(
TableRow _buildFancyIconFlatButtonRow() => _buildRow('FancyTextButton.icon', [
FancyTextButton.icon(
onPressed: () {},
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyFlatButton.icon(
FancyTextButton.icon(
onPressed: null,
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyFlatButton.icon(
FancyTextButton.icon(
isEnabled: false,
onPressed: () {},
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyFlatButton.icon(
FancyTextButton.icon(
onPressed: () {},
isLoading: true,
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyFlatButton.icon(
FancyTextButton.icon(
onPressed: () {},
isLoading: true,
loadingLabel: Text('loadingLabel'),
Expand All @@ -107,57 +107,57 @@ class ButtonsExample extends StatelessWidget {
),
]);

TableRow _buildFancyOutlineButtonRow() => _buildRow('FancyOutlineButton', [
FancyOutlineButton(
TableRow _buildFancyOutlinedButtonRow() => _buildRow('FancyOutlinedButton', [
FancyOutlinedButton(
onPressed: () {},
child: Text('child'),
),
FancyOutlineButton(
FancyOutlinedButton(
onPressed: null,
child: Text('child'),
),
FancyOutlineButton(
FancyOutlinedButton(
isEnabled: false,
onPressed: () {},
child: Text('child'),
),
FancyOutlineButton(
FancyOutlinedButton(
onPressed: () {},
isLoading: true,
child: Text('child'),
),
FancyOutlineButton(
FancyOutlinedButton(
onPressed: () {},
isLoading: true,
loadingChild: Text('loadingChild'),
child: Text('child'),
),
]);
TableRow _buildFancyIconOutlineButtonRow() =>
_buildRow('FancyOutlineButton.icon', [
FancyOutlineButton.icon(
_buildRow('FancyOutlinedButton.icon', [
FancyOutlinedButton.icon(
onPressed: () {},
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyOutlineButton.icon(
FancyOutlinedButton.icon(
onPressed: null,
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyOutlineButton.icon(
FancyOutlinedButton.icon(
isEnabled: false,
onPressed: () {},
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyOutlineButton.icon(
FancyOutlinedButton.icon(
onPressed: () {},
isLoading: true,
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyOutlineButton.icon(
FancyOutlinedButton.icon(
onPressed: () {},
isLoading: true,
loadingLabel: Text('loadingLabel'),
Expand All @@ -166,57 +166,57 @@ class ButtonsExample extends StatelessWidget {
),
]);

TableRow _buildFancyRaisedButtonRow() => _buildRow('FancyRaisedButton', [
FancyRaisedButton(
TableRow _buildFancyElevatedButtonRow() => _buildRow('FancyElevatedButton', [
FancyElevatedButton(
onPressed: () {},
child: Text('child'),
),
FancyRaisedButton(
FancyElevatedButton(
onPressed: null,
child: Text('child'),
),
FancyRaisedButton(
FancyElevatedButton(
isEnabled: false,
onPressed: () {},
child: Text('child'),
),
FancyRaisedButton(
FancyElevatedButton(
onPressed: () {},
isLoading: true,
child: Text('child'),
),
FancyRaisedButton(
FancyElevatedButton(
onPressed: () {},
isLoading: true,
loadingChild: Text('loadingChild'),
child: Text('child'),
),
]);
TableRow _buildFancyIconRaisedButtonRow() =>
_buildRow('FancyRaisedButton.icon', [
FancyRaisedButton.icon(
_buildRow('FancyElevatedButton.icon', [
FancyElevatedButton.icon(
onPressed: () {},
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyRaisedButton.icon(
FancyElevatedButton.icon(
onPressed: null,
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyRaisedButton.icon(
FancyElevatedButton.icon(
isEnabled: false,
onPressed: () {},
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyRaisedButton.icon(
FancyElevatedButton.icon(
onPressed: () {},
isLoading: true,
label: Text('label'),
icon: Icon(Icons.favorite),
),
FancyRaisedButton.icon(
FancyElevatedButton.icon(
onPressed: () {},
isLoading: true,
loadingLabel: Text('loadingLabel'),
Expand Down
22 changes: 10 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BottomSheetExample extends StatelessWidget {
return Section(
title: 'FancyBottomSheet',
children: <Widget>[
FancyRaisedButton(
FancyElevatedButton(
onPressed: () {
context.showFancyModalBottomSheet<void>(
builder: (_) => Padding(
Expand Down Expand Up @@ -82,9 +82,9 @@ class SeparatedButtonsExample extends StatelessWidget {
children: <Widget>[
SeparatedButtons(
children: <Widget>[
FlatButton(onPressed: () {}, child: Text('Imprint')),
FlatButton(onPressed: () {}, child: Text('Privacy Policy')),
FlatButton(onPressed: () {}, child: Text('Licenses')),
TextButton(onPressed: () {}, child: Text('Imprint')),
TextButton(onPressed: () {}, child: Text('Privacy Policy')),
TextButton(onPressed: () {}, child: Text('Licenses')),
],
),
],
Expand All @@ -107,7 +107,7 @@ class FillOrWrapExample extends StatelessWidget {
);
}

Widget _buildExample({bool isConstrained}) {
Widget _buildExample({required bool isConstrained}) {
return Center(
child: Container(
constraints: isConstrained ? BoxConstraints(maxWidth: 200) : null,
Expand All @@ -116,9 +116,9 @@ class FillOrWrapExample extends StatelessWidget {
spacing: 8,
wrappedSpacing: 8,
children: <Widget>[
RaisedButton(onPressed: () {}, child: Text('Short')),
RaisedButton(onPressed: () {}, child: Text('Loooooooooong')),
RaisedButton(onPressed: () {}, child: Text('Short')),
TextButton(onPressed: () {}, child: Text('Short')),
TextButton(onPressed: () {}, child: Text('Loooooooooong')),
TextButton(onPressed: () {}, child: Text('Short')),
],
),
),
Expand All @@ -127,10 +127,8 @@ class FillOrWrapExample extends StatelessWidget {
}

class Section extends StatelessWidget {
const Section({Key key, @required this.title, @required this.children})
: assert(title != null),
assert(children != null),
super(key: key);
const Section({Key? key, required this.title, required this.children})
: super(key: key);

final String title;
final List<Widget> children;
Expand Down
Loading

0 comments on commit 1dc1f04

Please sign in to comment.