Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ class SignInPage extends StatelessWidget {
},
),
const Divider(),
SignInButton(
Buttons.Facebook,
onPressed: () {
_showButtonPressDialog(context, 'Facebook (custom width)');
},
text: "This is a very long text that you can use",
width: 300.0,
),
const Divider(),
SignInButton(
Buttons.GoogleDark,
onPressed: () {
Expand Down
8 changes: 5 additions & 3 deletions lib/button_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class SignInButtonBuilder extends StatelessWidget {
this.shape,
this.height,
this.width,
}) : super(key: key);
}) : assert(width == null || width > 0, 'Width must be positive'),
assert(height == null || height > 0, 'Height must be positive'),
super(key: key);

/// The build function will be help user to build the signin button widget.
@override
Expand All @@ -95,8 +97,8 @@ class SignInButtonBuilder extends StatelessWidget {
Container _getButtonChild(BuildContext context) {
if (mini) {
return Container(
width: height ?? 35.0,
height: width ?? 35.0,
width: width ?? 35.0,
height: height ?? 35.0,
child: _getIconOrImage(),
);
}
Expand Down
20 changes: 20 additions & 0 deletions lib/button_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class SignInButton extends StatelessWidget {
// overrides the default button elevation
final double elevation;

/// overrides the default button width
final double? width;

/// The constructor is fairly self-explanatory.
const SignInButton(
this.button, {
Expand All @@ -42,12 +45,14 @@ class SignInButton extends StatelessWidget {
this.shape,
this.text,
this.elevation = 2.0,
this.width,
}) : assert(
mini != true ||
!(button == Buttons.Google ||
button == Buttons.GoogleDark ||
button == Buttons.FacebookNew),
'Google and FacebookNew buttons do not support mini mode'),
assert(width == null || width > 0, 'Width must be positive'),
super(key: key);

/// The build function is used to build the widget which will switch to
Expand Down Expand Up @@ -87,6 +92,7 @@ class SignInButton extends StatelessWidget {
innerPadding: const EdgeInsets.all(0),
shape: shape,
height: 36.0,
width: width,
);
case Buttons.Facebook:
case Buttons.FacebookNew:
Expand Down Expand Up @@ -116,6 +122,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.GitHub:
return SignInButtonBuilder(
Expand All @@ -128,6 +135,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Apple:
case Buttons.AppleDark:
Expand All @@ -145,6 +153,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.LinkedIn:
return SignInButtonBuilder(
Expand All @@ -157,6 +166,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Pinterest:
return SignInButtonBuilder(
Expand All @@ -169,6 +179,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Tumblr:
return SignInButtonBuilder(
Expand All @@ -181,6 +192,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Twitter:
return SignInButtonBuilder(
Expand All @@ -193,6 +205,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Reddit:
return SignInButtonBuilder(
Expand All @@ -205,6 +218,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Quora:
return SignInButtonBuilder(
Expand All @@ -216,6 +230,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Yahoo:
return SignInButtonBuilder(
Expand All @@ -227,6 +242,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Hotmail:
return SignInButtonBuilder(
Expand All @@ -238,6 +254,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Xbox:
return SignInButtonBuilder(
Expand All @@ -249,6 +266,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Microsoft:
return SignInButtonBuilder(
Expand All @@ -260,6 +278,7 @@ class SignInButton extends StatelessWidget {
onPressed: onPressed,
padding: padding,
shape: shape,
width: width,
);
case Buttons.Email:
default:
Expand All @@ -273,6 +292,7 @@ class SignInButton extends StatelessWidget {
padding: padding,
backgroundColor: Colors.grey[700]!,
shape: shape,
width: width,
);
}
}
Expand Down
Loading