LCOV - code coverage report
Current view: | top level - lib/PageHelpers - LiquidController.dart (source / functions) |  |  | Hit | Total | Coverage
Test: | lcov.info |  | Lines: | 11 | 11 | 100.0 %
Date: | 2021-03-10 21:05:26 |  | Functions: | 0 | 0 | -

              Line data    Source code
           1             : import 'package:flutter/material.dart';
           2             : import 'package:liquid_swipe/Provider/LiquidProvider.dart';
           3             : import 'package:liquid_swipe/liquid_swipe.dart';
           4             : import 'package:provider/provider.dart';
           5             :
           6             : /// Added in v1.5.0
           7             : ///
           8             : /// A controller class similar to [PageController] but with Limited Capabilities for now.
           9             : /// Provides method for dynamic changes to the [LiquidSwipe]
          10             : ///
          11             : /// Simple Usage :
          12             : ///
          13             : /// Firstly make an Object of [LiquidController] and initialize it in `initState()`
          14             : ///
          15             : /// ```dart
          16             : ///    LiquidController liquidController;
          17             : ///
          18             : ///    @override
          19             : ///    void initState() {
          20             : ///    super.initState();
          21             : ///    liquidController = LiquidController();
          22             : ///    }
          23             : /// ```
          24             : ///
          25             : /// Now simply add it to [LiquidSwipe]'s Constructor
          26             : ///
          27             : /// ```dart
          28             : ///    LiquidSwipe(
          29             : ///         pages: pages,
          30             : ///         LiquidController: liquidController,
          31             : ///     ),
          32             : ///
          33             : /// ```
          34             : ///
          35             : /// Only Rules/Limitation to its Usage is For now you can't use any method in Liquid Controller before build method is being called in which [LiquidSwipe] is initialized
          36             : ///
          37             : /// So we have to use them after LiquidSwipe is Built
          38             : ///
          39             : ///
          40             : class LiquidController {
          41             :   ///Provider model calls (not listenable) just used for calling its internal methods
          42             :   late LiquidProvider provider;
          43             :
          44           1 :   LiquidController();
          45             :
          46             :   ///Internal Method Should not be used.
          47           1 :   setContext(BuildContext context) {
          48           2 :     provider = Provider.of<LiquidProvider>(context, listen: false);
          49             :   }
          50             :
          51             :   ///Jump Directly to mentioned Page index but without Animation
          52             :   ///see also : [LiquidProvider.jumpToPage]
          53           1 :   jumpToPage({required int page}) {
          54           2 :     provider.jumpToPage(page);
          55             :   }
          56             :
          57             :   ///Animate to mentioned page within given [Duration]
          58             :   ///Remember the [duration] here is the total duration in which it will animate though all pages not the single page
          59           1 :   animateToPage({required int page, int duration = 600}) {
          60           2 :     provider.animateToPage(page, duration);
          61             :   }
          62             :
          63             :   ///Getter to get current Page
          64             :   ///see also : [OnPageChangeCallback]
          65           3 :   int get currentPage => provider.activePageIndex;
          66             :
          67             :   ///Use this method to disable gestures during runtime, like on certain pages using [OnPageChangeCallback]
          68             :   ///If you want to disable gestures from start use [LiquidSwipe.disableUserGesture]
          69           1 :   shouldDisableGestures({required bool disable}) {
          70           2 :     provider.setUserGesture = disable;
          71             :   }
          72             :
          73             :   ///If somehow you want to check if gestures are disabled or not
          74             :   ///Returns [bool]
          75           3 :   bool get isUserGestureDisabled => provider.isUserGestureDisabled;
          76             : }

Generated by: LCOV version 1.15