-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🩹Updated: Updated name of parameter and also added support for the fl…
…oatingAction Widget for the default showcase widget
- Loading branch information
1 parent
7915a3b
commit f2d362e
Showing
7 changed files
with
270 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class FloatingActionWidget extends StatelessWidget { | ||
const FloatingActionWidget({ | ||
super.key, | ||
required this.child, | ||
this.right, | ||
this.width, | ||
this.height, | ||
this.left, | ||
this.bottom, | ||
this.top, | ||
}); | ||
|
||
/// This is same as the Positioned.directional widget | ||
/// Creates a widget that controls where a child of a [Stack] is positioned. | ||
/// | ||
/// Only two out of the three horizontal values (`start`, `end`, | ||
/// [width]), and only two out of the three vertical values ([top], | ||
/// [bottom], [height]), can be set. In each case, at least one of | ||
/// the three must be null. | ||
/// | ||
/// If `textDirection` is [TextDirection.rtl], then the `start` argument is | ||
/// used for the [right] property and the `end` argument is used for the | ||
/// [left] property. Otherwise, if `textDirection` is [TextDirection.ltr], | ||
/// then the `start` argument is used for the [left] property and the `end` | ||
/// argument is used for the [right] property. | ||
factory FloatingActionWidget.directional({ | ||
Key? key, | ||
required TextDirection textDirection, | ||
required Widget child, | ||
double? start, | ||
double? top, | ||
double? end, | ||
double? bottom, | ||
double? width, | ||
double? height, | ||
}) { | ||
double? left; | ||
double? right; | ||
switch (textDirection) { | ||
case TextDirection.rtl: | ||
left = end; | ||
right = start; | ||
break; | ||
case TextDirection.ltr: | ||
left = start; | ||
right = end; | ||
} | ||
return FloatingActionWidget( | ||
key: key, | ||
left: left, | ||
top: top, | ||
right: right, | ||
bottom: bottom, | ||
width: width, | ||
height: height, | ||
child: child, | ||
); | ||
} | ||
|
||
/// The widget below this widget in the tree. | ||
/// | ||
/// {@macro flutter.widgets.ProxyWidget.child} | ||
final Widget child; | ||
|
||
/// The distance that the child's left edge is inset from the left of the stack. | ||
/// | ||
/// Only two out of the three horizontal values ([left], [right], [width]) can be | ||
/// set. The third must be null. | ||
/// | ||
/// If all three are null, the [Stack.alignment] is used to position the child | ||
/// horizontally. | ||
final double? left; | ||
|
||
/// The distance that the child's top edge is inset from the top of the stack. | ||
/// | ||
/// Only two out of the three vertical values ([top], [bottom], [height]) can be | ||
/// set. The third must be null. | ||
/// | ||
/// If all three are null, the [Stack.alignment] is used to position the child | ||
/// vertically. | ||
final double? top; | ||
|
||
/// The distance that the child's right edge is inset from the right of the stack. | ||
/// | ||
/// Only two out of the three horizontal values ([left], [right], [width]) can be | ||
/// set. The third must be null. | ||
/// | ||
/// If all three are null, the [Stack.alignment] is used to position the child | ||
/// horizontally. | ||
final double? right; | ||
|
||
/// The distance that the child's bottom edge is inset from the bottom of the stack. | ||
/// | ||
/// Only two out of the three vertical values ([top], [bottom], [height]) can be | ||
/// set. The third must be null. | ||
/// | ||
/// If all three are null, the [Stack.alignment] is used to position the child | ||
/// vertically. | ||
final double? bottom; | ||
|
||
/// The child's width. | ||
/// | ||
/// Only two out of the three horizontal values ([left], [right], [width]) can be | ||
/// set. The third must be null. | ||
/// | ||
/// If all three are null, the [Stack.alignment] is used to position the child | ||
/// horizontally. | ||
final double? width; | ||
|
||
/// The child's height. | ||
/// | ||
/// Only two out of the three vertical values ([top], [bottom], [height]) can be | ||
/// set. The third must be null. | ||
/// | ||
/// If all three are null, the [Stack.alignment] is used to position the child | ||
/// vertically. | ||
final double? height; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Positioned( | ||
key: key, | ||
left: left, | ||
top: top, | ||
right: right, | ||
bottom: bottom, | ||
width: width, | ||
height: height, | ||
child: child, | ||
); | ||
} | ||
} |