fix: documentation fixes

This commit is contained in:
TimIconica 2022-09-20 11:58:06 +02:00
parent 16262dc75d
commit 11c8fcde73
11 changed files with 53 additions and 42 deletions

View file

@ -5,15 +5,15 @@ import 'package:flutter/material.dart';
/// The pages determine what pages the pageview will contain via a [List] of [ShellFormPage]s. /// The pages determine what pages the pageview will contain via a [List] of [ShellFormPage]s.
/// ///
/// Using a checkpage gives the ability for the user to check all input values before commiting by [CheckPage]. /// Using a checkpage gives the ability for the user to check all input values before commiting by [CheckPage].
/// If [checkpage] is null no check page will be shown. /// If [checkPage] is null no check page will be shown.
/// ///
/// [nextButton] and [backButton] are both a way to give controls to user. /// [nextButton] and [backButton] are both a way to give controls to user.
/// Both are just plain widgets used in a [Stack]. So the widgets can be aligned where ever. /// Both are just plain widgets used in a [Stack]. So the widgets can be aligned where ever.
/// The formcontroller of [ShellForm] should be used to give control to the widgets/buttons. /// The formcontroller of [ShellForm] should be used to give control to the widgets/buttons.
/// ///
/// [onFinished] and [onNext] are both callbacks which give the users results. /// [onFinished] and [onNext] are both callbacks which give the users results.
/// onNext is called when the user goes to the next page. /// [onNext] is called when the user goes to the next page.
/// onFinished is called when the form is finished. When checkpage is set onFinished is called when the checkpage is finished. /// [onFinished] is called when the form is finished. When checkpage is set [onFinished] is called when the checkpage is finished.
class ShellFormOptions { class ShellFormOptions {
final List<ShellFormPage> pages; final List<ShellFormPage> pages;

View file

@ -1,5 +1,6 @@
import 'package:flutter_form/next_shell/translation_service.dart'; import 'package:flutter_form/next_shell/translation_service.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
/// Provides the [ShellTranslationService]
final translationServiceProvider = final translationServiceProvider =
Provider<TranslationService>((ref) => ShellTranslationService()); Provider<TranslationService>((ref) => ShellTranslationService());

View file

@ -31,13 +31,13 @@ abstract class ShellFormInputWidget extends ConsumerWidget {
/// Abstract class for the controller for inputs used in a [ShellForm]. /// Abstract class for the controller for inputs used in a [ShellForm].
/// ///
/// The id determines the key in the [Map] returned by the [ShellForm]. /// The [id] determines the key in the [Map] returned by the [ShellForm].
/// ///
/// value is a way to set a initial value. /// [value] is a way to set a initial value.
/// ///
/// mandatory determines if the input is mandatory. /// [mandatory] determines if the input is mandatory.
/// ///
/// checkPageTitle is a function where you can transform the value from the input into something representable. /// [checkPageTitle] is a function where you can transform the value from the input into something representable.
/// This value will be given when defining the check page widgets. /// This value will be given when defining the check page widgets.
/// If this function is not set, the value will be used as is. /// If this function is not set, the value will be used as is.
/// Example: /// Example:
@ -47,7 +47,7 @@ abstract class ShellFormInputWidget extends ConsumerWidget {
/// }, /// },
/// ``` /// ```
/// ///
/// checkPageDescription is the same as checkPageTitle but for the description. /// [checkPageDescription] is the same as checkPageTitle but for the description.
/// If null no description will be shown. /// If null no description will be shown.
abstract class ShellFormInputController<T> { abstract class ShellFormInputController<T> {
String? id; String? id;

View file

@ -100,7 +100,8 @@ class CarouselControllerImpl implements CarouselController {
return _state!.pageController!.jumpToPage(pageToJump); return _state!.pageController!.jumpToPage(pageToJump);
} }
/// Animates the controlled [CarouselSlider] from the current page to the given page. /// Animates the controlled [CarouselSlider] from the current page to the
/// given page.
/// ///
/// The animation lasts for the given duration and follows the given curve. /// The animation lasts for the given duration and follows the given curve.
/// The returned [Future] resolves when the animation completes. /// The returned [Future] resolves when the animation completes.
@ -136,7 +137,8 @@ class CarouselControllerImpl implements CarouselController {
/// Stops the controlled [CarouselSlider] from autoplaying. /// Stops the controlled [CarouselSlider] from autoplaying.
/// ///
/// This is a more on-demand way of doing this. Use the [autoPlay] /// This is a more on-demand way of doing this. Use the [autoPlay]
/// parameter in [CarouselOptions] to specify the autoPlay behaviour of the carousel. /// parameter in [CarouselOptions] to specify the autoPlay behaviour of the
/// carousel.
@override @override
void stopAutoPlay() { void stopAutoPlay() {
_state!.onResetTimer(); _state!.onResetTimer();

View file

@ -35,17 +35,17 @@ class CarouselOptions {
/// Enables auto play, sliding one page at a time. /// Enables auto play, sliding one page at a time.
/// ///
/// Use [autoPlayInterval] to determent the frequency of slides. /// Use [autoPlayInterval] to determine the frequency of slides.
/// Defaults to false. /// Defaults to false.
final bool autoPlay; final bool autoPlay;
/// Sets Duration to determent the frequency of slides when /// Sets Duration to determine the frequency of slides when [autoPlay] is set
/// /// to true.
/// [autoPlay] is set to true.
/// Defaults to 4 seconds. /// Defaults to 4 seconds.
final Duration autoPlayInterval; final Duration autoPlayInterval;
/// The animation duration between two transitioning pages while in auto playback. /// The animation duration between two transitioning pages while in auto
/// playback.
/// ///
/// Defaults to 800 ms. /// Defaults to 800 ms.
final Duration autoPlayAnimationDuration; final Duration autoPlayAnimationDuration;
@ -88,40 +88,46 @@ class CarouselOptions {
/// Default to `true`. /// Default to `true`.
final bool pageSnapping; final bool pageSnapping;
/// If `true`, the auto play function will be paused when user is interacting with /// If `true`, the auto play function will be paused when user is interacting
/// the carousel, and will be resumed when user finish interacting. /// with the carousel, and will be resumed when user finish interacting.
///
/// Default to `true`. /// Default to `true`.
final bool pauseAutoPlayOnTouch; final bool pauseAutoPlayOnTouch;
/// If `true`, the auto play function will be paused when user is calling /// If `true`, the auto play function will be paused when user is calling
/// pageController's `nextPage` or `previousPage` or `animateToPage` method. /// [PageController]'s [nextPage] or [previousPage] or [animateToPage] method.
/// And after the animation complete, the auto play will be resumed. /// And after the animation complete, the auto play will be resumed.
///
/// Default to `true`. /// Default to `true`.
final bool pauseAutoPlayOnManualNavigate; final bool pauseAutoPlayOnManualNavigate;
/// If `enableInfiniteScroll` is `false`, and `autoPlay` is `true`, this option /// If [enableInfiniteScroll] is `false`, and [autoPlay] is `true`, this option
/// decide the carousel should go to the first item when it reach the last item or not. /// decide the carousel should go to the first item when it reach the last item or not.
/// If set to `true`, the auto play will be paused when it reach the last item. /// If set to `true`, the auto play will be paused when it reach the last item.
/// If set to `false`, the auto play function will animate to the first item when it was /// If set to `false`, the auto play function will animate to the first item
/// in the last item. /// when it was in the last item.
final bool pauseAutoPlayInFiniteScroll; final bool pauseAutoPlayInFiniteScroll;
/// Pass a `PageStoragekey` if you want to keep the pageview's position when it was recreated. /// Pass a [PageStorageKey] if you want to keep the pageview's position when
/// it was recreated.
final PageStorageKey? pageViewKey; final PageStorageKey? pageViewKey;
/// Use `enlargeStrategy` to determine which method to enlarge the center page. /// Use [enlargeStrategy] to determine which method to enlarge the center page.
final CenterPageEnlargeStrategy enlargeStrategy; final CenterPageEnlargeStrategy enlargeStrategy;
/// Whether or not to disable the `Center` widget for each slide. /// Whether or not to disable the [Center] widget for each slide.
final bool disableCenter; final bool disableCenter;
/// Whether to add padding to both ends of the list. /// Whether to add padding to both ends of the list.
/// If this is set to true and [viewportFraction] < 1.0, padding will be added such that the first and last child slivers will be in the center of the viewport when scrolled all the way to the start or end, respectively. /// If this is set to true and [viewportFraction] < 1.0, padding will be added
/// such that the first and last child slivers will be in the center of the 1
/// viewport when scrolled all the way to the start or end, respectively.
///
/// If [viewportFraction] >= 1.0, this property has no effect. /// If [viewportFraction] >= 1.0, this property has no effect.
/// This property defaults to true and must not be null. /// This property defaults to true and must not be null.
final bool padEnds; final bool padEnds;
/// Exposed clipBehavior of PageView /// Exposed [clipBehavior] of [PageView]
final Clip clipBehavior; final Clip clipBehavior;
CarouselOptions({ CarouselOptions({

View file

@ -17,14 +17,14 @@ typedef ExtendedIndexedWidgetBuilder = Widget Function(
BuildContext context, int index, int realIndex); BuildContext context, int index, int realIndex);
class CarouselSlider extends StatefulWidget { class CarouselSlider extends StatefulWidget {
/// [CarouselOptions] to create a [CarouselState] with /// [CarouselOptions] to create a [CarouselState] with.
final CarouselOptions options; final CarouselOptions options;
/// The widgets to be shown in the carousel of default constructor /// The widgets to be shown in the carousel of default constructor.
final List<Widget>? items; final List<Widget>? items;
/// The widget item builder that will be used to build item on demand /// The widget item builder that will be used to build item on demand
/// The third argument is the PageView's real index, can be used to cooperate /// The third argument is the [PageView]'s real index, can be used to cooperate
/// with Hero. /// with Hero.
final ExtendedIndexedWidgetBuilder? itemBuilder; final ExtendedIndexedWidgetBuilder? itemBuilder;
@ -45,7 +45,7 @@ class CarouselSlider extends StatefulWidget {
: CarouselController() as CarouselControllerImpl, : CarouselController() as CarouselControllerImpl,
super(key: key); super(key: key);
/// The on demand item builder constructor /// The on demand item builder constructor/
CarouselSlider.builder( CarouselSlider.builder(
{required this.itemCount, {required this.itemCount,
required this.itemBuilder, required this.itemBuilder,
@ -73,7 +73,7 @@ class CarouselSliderState extends State<CarouselSlider>
PageController? pageController; PageController? pageController;
/// mode is related to why the page is being changed /// [mode] is related to why the page is being changed
CarouselPageChangedReason mode = CarouselPageChangedReason.controller; CarouselPageChangedReason mode = CarouselPageChangedReason.controller;
CarouselSliderState(); CarouselSliderState();

View file

@ -23,7 +23,7 @@ class CarouselState {
/// The widgets count that should be shown at carousel /// The widgets count that should be shown at carousel
int? itemCount; int? itemCount;
/// Will be called when using pageController to go to next page or /// Will be called when using [pageController] to go to next page or
/// previous page. It will clear the autoPlay timer. /// previous page. It will clear the autoPlay timer.
/// Internal use only /// Internal use only
Function onResetTimer; Function onResetTimer;

View file

@ -17,7 +17,7 @@ class ShellFormInputPassword extends ShellFormInputWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
super.registerController(context); super.registerController(context);
return PasswordTextfield( return PasswordTextField(
label: label, label: label,
controller: controller, controller: controller,
); );
@ -62,11 +62,11 @@ class ShellFormInputPasswordController
String Function(String, {List<String>? params}) translator) { String Function(String, {List<String>? params}) translator) {
if (mandatory) { if (mandatory) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return translator('shell.form.error.empty'); return translator('Field cannot be empty');
} }
if (value.length < 6) { if (value.length < 6) {
return translator('shell.form.error.empty'); return translator('Field cannot be empty');
} }
} }

View file

@ -3,21 +3,23 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../../../flutter_form.dart'; import '../../../../../flutter_form.dart';
import 'package:flutter_form/next_shell/translation_service.dart'; import 'package:flutter_form/next_shell/translation_service.dart';
class PasswordTextfield extends ConsumerStatefulWidget { /// Generates a [TextFormField] for passwords. It requires a [ShellFormInputController]
/// as the [controller] parameter and an optional [Widget] as [label]
class PasswordTextField extends ConsumerStatefulWidget {
final Widget? label; final Widget? label;
final ShellFormInputController controller; final ShellFormInputController controller;
const PasswordTextfield({ const PasswordTextField({
Key? key, Key? key,
required this.controller, required this.controller,
this.label, this.label,
}) : super(key: key); }) : super(key: key);
@override @override
ConsumerState<PasswordTextfield> createState() => _PasswordTextfieldState(); ConsumerState<PasswordTextField> createState() => _PasswordTextFieldState();
} }
class _PasswordTextfieldState extends ConsumerState<PasswordTextfield> { class _PasswordTextFieldState extends ConsumerState<PasswordTextField> {
bool obscured = true; bool obscured = true;
@override @override

View file

@ -4,7 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../../flutter_form.dart'; import '../../../../flutter_form.dart';
import 'package:flutter_form/next_shell/translation_service.dart'; import 'package:flutter_form/next_shell/translation_service.dart';
/// Input for an plain text used in a [ShellForm]. /// Input for plain text input used in a [ShellForm].
/// ///
/// Standard controller is [ShellFormInputPlainTextController]. /// Standard controller is [ShellFormInputPlainTextController].
class ShellFormInputPlainText extends ShellFormInputWidget { class ShellFormInputPlainText extends ShellFormInputWidget {
@ -73,7 +73,7 @@ class ShellFormInputPlainTextWhiteWithBorder extends ShellFormInputWidget {
} }
} }
/// Controller for plain text used by a [ShellFormInputWidget] used in a [ShellFrom]. /// Controller for plain text used by a [ShellFormInputWidget] used in a [ShellForm].
/// ///
/// Mainly used by [ShellFormInputPlainText]. /// Mainly used by [ShellFormInputPlainText].
class ShellFormInputPlainTextController class ShellFormInputPlainTextController

View file

@ -35,7 +35,7 @@ class ShellFormInputSlider extends ShellFormInputWidget {
} }
} }
/// Controller for slider used by a [ShellFormInputWidget] used in a [ShellFrom]. /// Controller for slider used by a [ShellFormInputWidget] used in a [ShellForm].
/// ///
/// Mainly used by [ShellFormInputSlider]. /// Mainly used by [ShellFormInputSlider].
class ShellFormInputSliderController class ShellFormInputSliderController