AfAnimations constructor

const AfAnimations({
  1. Key? key,
  2. required Widget child,
  3. Duration? duration,
  4. Curve? curve,
  5. void onEnd()?,
  6. 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.

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"]);

Implementation

const AfAnimations({
  super.key,
  required this.child,
  this.duration,
  this.curve,
  this.onEnd,
  this.showRepaint = false,
});