brex900 / flutter_extensions Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
class KeyboardRemover extends StatefulWidget {
final Widget child;
const KeyboardRemover({Key key, @required this.child}) : super(key: key);
@override
_KeyboardRemoverState createState() => _KeyboardRemoverState();
}
class _KeyboardRemoverState extends State<KeyboardRemover> {
FocusNode _focusPuller;
final _focusNode = FocusNode();
@override
void didChangeDependencies() {
super.didChangeDependencies();
_focusPuller = Focus.of(context);
}
void _requestFocus() {
if (_focusNode.hasFocus) return;
_focusPuller.requestFocus(_focusNode);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _requestFocus,
child: widget.child,
);
}
}
class InkStack extends StatelessWidget {
final VoidCallback onTap;
final List<Widget> background;
final List<Widget> foreground;
const InkStack({
Key key,
this.onTap,
this.background = const <Widget>[],
this.foreground = const <Widget>[],
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: [
...background,
Positioned.fill(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
),
),
),
...foreground,
],
);
}
}
extension SizeFlutterExtensions on Size {
Size copyWith({double width, double height}) {
return Size(width ?? this.width, height ?? this.height);
}
}
class ButtonStyleBuilder {
/// [ButtonStyle.textStyle]
final TextStyle textStyle;
/// [ButtonStyle.backgroundColor]
final Color backgroundColor;
/// [ButtonStyle.foregroundColor]
final Color foregroundColor;
/// [ButtonStyle.overlayColor]
final Color overlayColor;
/// [ButtonStyle.shadowColor]
final Color shadowColor;
/// [ButtonStyle.elevation]
final double elevation;
/// [ButtonStyle.padding]
final EdgeInsetsGeometry padding;
/// [ButtonStyle.minimumSize]
final Size minimumSize;
/// [ButtonStyle.side]
final BorderSide side;
/// [ButtonStyle.shape]
final OutlinedBorder shape;
/// [ButtonStyle.mouseCursor]
final MouseCursor mouseCursor;
/// [ButtonStyle.visualDensity]
final VisualDensity visualDensity;
/// [ButtonStyle.tapTargetSize]
final MaterialTapTargetSize tapTargetSize;
/// [ButtonStyle.animationDuration]
final Duration animationDuration;
/// [ButtonStyle.enableFeedback]
final bool enableFeedback;
const ButtonStyleBuilder({
this.textStyle,
this.backgroundColor,
this.foregroundColor,
this.overlayColor,
this.shadowColor,
this.elevation,
this.padding,
this.minimumSize,
this.side,
this.shape,
this.mouseCursor,
this.visualDensity,
this.tapTargetSize,
this.animationDuration,
this.enableFeedback,
});
ButtonStyleBuilder copyWith({
TextStyle textStyle,
Color backgroundColor,
Color foregroundColor,
Color overlayColor,
Color shadowColor,
double elevation,
EdgeInsetsGeometry padding,
Size minimumSize,
BorderSide side,
OutlinedBorder shape,
MouseCursor mouseCursor,
VisualDensity visualDensity,
MaterialTapTargetSize tapTargetSize,
Duration animationDuration,
bool enableFeedback,
}) {
return new ButtonStyleBuilder(
textStyle: textStyle ?? this.textStyle,
backgroundColor: backgroundColor ?? this.backgroundColor,
foregroundColor: foregroundColor ?? this.foregroundColor,
overlayColor: overlayColor ?? this.overlayColor,
shadowColor: shadowColor ?? this.shadowColor,
elevation: elevation ?? this.elevation,
padding: padding ?? this.padding,
minimumSize: minimumSize ?? this.minimumSize,
side: side ?? this.side,
shape: shape ?? this.shape,
mouseCursor: mouseCursor ?? this.mouseCursor,
visualDensity: visualDensity ?? this.visualDensity,
tapTargetSize: tapTargetSize ?? this.tapTargetSize,
animationDuration: animationDuration ?? this.animationDuration,
enableFeedback: enableFeedback ?? this.enableFeedback,
);
}
ButtonStyle build() {
return ButtonStyle(
textStyle: MaterialStateProperty.all(textStyle),
backgroundColor: MaterialStateProperty.all(backgroundColor),
foregroundColor: MaterialStateProperty.all(foregroundColor),
overlayColor: MaterialStateProperty.all(overlayColor),
shadowColor: MaterialStateProperty.all(shadowColor),
elevation: MaterialStateProperty.all(elevation),
padding: MaterialStateProperty.all(padding),
minimumSize: MaterialStateProperty.all(minimumSize),
side: MaterialStateProperty.all(side),
shape: MaterialStateProperty.all(shape),
mouseCursor: MaterialStateProperty.all(mouseCursor),
visualDensity: visualDensity,
tapTargetSize: tapTargetSize,
animationDuration: animationDuration,
enableFeedback: enableFeedback,
);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.