Skip to content

HTD-Health/flutter_widgets_library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter widgets library


Getting started

To add a widget to your app:

  1. Add this to your pubspec.yaml file.

    dependencies:
      widgets_library:
        git: git@github.com:HTD-Health/flutter_widgets_library.git
  2. You are ready! 😉


Loaders

SpringLoader

example

CircleLoader

example

DotsLoader

example

Buttons

FadeButton

A widget that provides a fade effect when a tap gesture is performed on its child.

example

Layouts

SeparatedChildBuilderDelegate

This delegate can be used together with SliverList to provide a solution similar to ListView.separated.

Example:

class SeparatedChildBuilderDelegateExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final items = ['item 1', 'item 2', 'item 3'];

    return CustomScrollView(
      slivers: [
        SliverList(
          delegate: SeparatedChildBuilderDelegate(
            childCount: items.length,
            itemBuilder: (BuildContext context, int index) => Text(items[index]),
            separatorBuilder: (BuildContext context, int index) => const SizedBox(height: 24),
          )
        )
      ],
    );
  }
}

Widgets

AsyncCallbackBuilder

A widget that encapsulates asynchronously running procedures with automatic state updates.

Delayed

Widget that displays its' child after the given [duration].

Widget build(BuildContext context) {
  /// The progress indicator widget will be displayed
  /// after a delay of 2 seconds
  return Delayed(
    duration: Duration(seconds: 2),
    child: CircularProgressIndicator(),
  );
}

IsScrolled

Widget that provides information on whether the scrollable is scrolled more than a given offset or has more than offset to scroll.

When there are no clients (the controller is not attached to the scrolling widget), the state is all set to false. Since there is no scrollable, nothing can/or is scrolled. The same applies to the SingleChildScrollView widget with smaller content that its size.

Example usage:

Widget build(BuildContext context) {
  return IsScrolled(
    builder: (context, scrollController, scrollState) {
      return Scaffold(
        appBar: AppBar(
          title: Text('The list is scrolled: ${scrollState.isScrolled}'),
        ),
        body: ListView.builder(
          controller: scrollController,
          itemBuilder: (context, index) => /* *** */,
        ),
      );
    },
  );
}