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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# Since this is an library
/pubspec.lock
16 changes: 8 additions & 8 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,14 +21,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -73,14 +73,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -141,7 +141,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.4.3"
typed_data:
dependency: transitive
description:
Expand All @@ -155,6 +155,6 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.14.0 <3.0.0"
50 changes: 38 additions & 12 deletions lib/src/extensions/widget_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ typedef GestureOnTapChangeCallback = void Function(bool tapState);

extension StyledWidget on Widget {
_StyledAnimatedModel _getAnimation(BuildContext context) {
_StyledAnimatedModel? animation = _StyledInheritedAnimation.of(context)?.animation;
_StyledAnimatedModel? animation =
_StyledInheritedAnimation.of(context)?.animation;
assert(animation != null,
'[styled_widget]: You can`t animate without defining the animation. Call the method animate() higher in your widget hierarchy to define an animation');
return animation!;
Expand Down Expand Up @@ -33,7 +34,8 @@ extension StyledWidget on Widget {
/// Widget build(BuildContext) => childWidget
/// .parent(parentWidget);
/// ```
Widget parent(Widget Function({required Widget child}) parent) => parent(child: this);
Widget parent(Widget Function({required Widget child}) parent) =>
parent(child: this);

Widget padding({
Key? key,
Expand Down Expand Up @@ -558,10 +560,15 @@ extension StyledWidget on Widget {
}) {
BoxDecoration decoration = BoxDecoration(
border: Border(
left: (left ?? all) == null ? BorderSide.none : BorderSide(color: color, width: left ?? all ?? 0, style: style),
right:
(right ?? all) == null ? BorderSide.none : BorderSide(color: color, width: right ?? all ?? 0, style: style),
top: (top ?? all) == null ? BorderSide.none : BorderSide(color: color, width: top ?? all ?? 0, style: style),
left: (left ?? all) == null
? BorderSide.none
: BorderSide(color: color, width: left ?? all ?? 0, style: style),
right: (right ?? all) == null
? BorderSide.none
: BorderSide(color: color, width: right ?? all ?? 0, style: style),
top: (top ?? all) == null
? BorderSide.none
: BorderSide(color: color, width: top ?? all ?? 0, style: style),
bottom: (bottom ?? all) == null
? BorderSide.none
: BorderSide(color: color, width: bottom ?? all ?? 0, style: style),
Expand Down Expand Up @@ -630,7 +637,8 @@ extension StyledWidget on Widget {
);
}

double _elevationOpacityCurve(double x) => pow(x, 1 / 16) / sqrt(pow(x, 2) + 2) + 0.2;
double _elevationOpacityCurve(double x) =>
pow(x, 1 / 16) / sqrt(pow(x, 2) + 2) + 0.2;

// TODO: Animate elevation
Widget elevation(
Expand Down Expand Up @@ -773,7 +781,9 @@ extension StyledWidget on Widget {
minHeight: minHeight,
maxHeight: maxHeight,
);
constraints = (width != null || height != null) ? constraints.tighten(width: width, height: height) : constraints;
constraints = (width != null || height != null)
? constraints.tighten(width: width, height: height)
: constraints;
return animate
? _StyledAnimatedBuilder(
key: key,
Expand Down Expand Up @@ -861,7 +871,8 @@ extension StyledWidget on Widget {
key: key,
builder: (BuildContext context) {
// TODO: PERFORMANCE: findAncestorWidgetOfExactType vs InheritedWidget performance
GestureDetector? gestures = context.findAncestorWidgetOfExactType<GestureDetector>();
GestureDetector? gestures =
context.findAncestorWidgetOfExactType<GestureDetector>();
return Material(
color: Colors.transparent,
child: InkWell(
Expand Down Expand Up @@ -937,7 +948,8 @@ extension StyledWidget on Widget {
builder: (animation) {
return _AnimatedTransform(
child: this,
transform: Matrix4.diagonal3Values(x ?? all ?? 0, y ?? all ?? 0, 1.0),
transform: Matrix4.diagonal3Values(
x ?? all ?? 0, y ?? all ?? 0, 1.0),
alignment: alignment,
transformHitTests: transformHitTests,
duration: animation.duration,
Expand All @@ -947,7 +959,8 @@ extension StyledWidget on Widget {
)
: Transform(
key: key,
transform: Matrix4.diagonal3Values(x ?? all ?? 0, y ?? all ?? 0, 1.0),
transform:
Matrix4.diagonal3Values(x ?? all ?? 0, y ?? all ?? 0, 1.0),
alignment: alignment,
child: this,
origin: origin,
Expand All @@ -966,7 +979,8 @@ extension StyledWidget on Widget {
builder: (animation) {
return _AnimatedTransform(
child: this,
transform: Matrix4.translationValues(offset.dx, offset.dy, 0.0),
transform:
Matrix4.translationValues(offset.dx, offset.dy, 0.0),
transformHitTests: transformHitTests,
duration: animation.duration,
curve: animation.curve,
Expand Down Expand Up @@ -1358,4 +1372,16 @@ extension StyledWidget on Widget {
semanticContainer: semanticContainer,
child: this,
);

Widget limitedBox({
Key? key,
double maxWidth = double.infinity,
double maxHeight = double.infinity,
}) =>
LimitedBox(
key: key,
maxWidth: maxWidth,
maxHeight: maxHeight,
child: this,
);
}
153 changes: 0 additions & 153 deletions pubspec.lock

This file was deleted.