AfAnimations class
The AfAnimations widget serves to globally set the duration and curve for all used AfWidgets. You can retrieve the specified data here. Below this, you can see how it is done.
All the documentation was created with the help of GPT-4. If you find any errors, please let me know by starting a new discussion or PR :) https://github.com/FernandoDev007/af_animations
Examples:
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
/// You can also add it to a specific screen to apply it only screen
return AfAnimations(
// You will be able to specify the duration of animations globally
duration: const Duration(milliseconds: 500),
// You will be able to specify the curve of animations globally
curve: Curves.easeInOut,
// Only for testing
showRepaint: true,
child: MaterialApp(
...
),
);
}
}
Afterwards, in your project, you will be able to retrieve the globally specified values as follows:
Duration globalDuration = AfAnimations.getDuration(context);
Curve globalCurve = AfAnimations.getCurve(context);
bool? showRepaint = AfAnimations.isShowRepaint(context);
You can also use these others:
bool existsAncestor = AfAnimations.existsAncestor(context);
/// If for any reason you want to use it.
AfAnimations.callOnEnd(context);
/// Update all AfWidgets without a specified ID.
AfAnimations.update(context);
/// You specify the IDs to update, and it will update the widget entirely in an optimal way.
AfAnimations.update(context, ids: ["updateIcon", "updateValue", "Anothers"]);
These functions will work in these AfWidgets
Alternative without context to AfAnimations: AfController
The alternative to AfAnimations without context, for those suffering from "Contextphobia"... The AfController is used to set the duration, curve, and other animations for a specified group of AfWidgets.
AfAnimations is easier and simpler to use in the application, but AfController is a context-free alternative. I assure you that each one has different use cases, and it will be up to your preference to choose between them.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- AfAnimations
- Available extensions
Constructors
- AfAnimations({Key? key, required Widget child, Duration? duration, Curve? curve, void onEnd()?, bool showRepaint = false})
-
The AfAnimations widget serves to globally set the duration and curve for all used AfWidgets.
You can retrieve the specified data here. Below this, you can see how it is done.
const
Properties
- child → Widget
-
The widget below this widget in the tree.
final
- curve → Curve?
-
The global curve over which the AfWidgets will be animated.
final
- duration → Duration?
-
The global duration over which the AfWidgets will be animated.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onEnd → void Function()?
-
Called every time an animation completes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showRepaint → bool
-
If the showRepaint widget extension is set to true
(You can use it in your current project to perform performance tests),
all widget rebuilds will be visually displayed, making it easier to identify areas
where performance can be improved, by avoiding unnecessary rebuilds.
final
Methods
-
afShowRepaint(
BuildContext context, {AfController? controller}) → Widget -
Available on Widget, provided by the AfWidgetsExtension extension
If the showRepaint widget extension is set to true (You can use it in your current project to perform performance tests), all widget rebuilds will be visually displayed, making it easier to identify areas where performance can be improved, by avoiding unnecessary rebuilds. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< AfAnimations> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
callOnEnd(
BuildContext context) → void - You can also use these others:
-
existsAncestor(
BuildContext context) → bool - Check if there is an ancestor AfAnimations and perform an action based on that You can also use these others:
-
getCurve(
BuildContext context) → Curve - Afterwards, in your project, you will be able to retrieve the globally specified values as follows:
-
getDuration(
BuildContext context) → Duration - Afterwards, in your project, you will be able to retrieve the globally specified values as follows:
-
isShowRepaint(
BuildContext context) → bool? - Afterwards, in your project, you will be able to retrieve the globally specified values as follows:
-
update(
BuildContext context, {List< String> ids = const <String>[""]}) → void - You can also use these others: