with_loader 0.0.2 with_loader: ^0.0.2 copied to clipboard
A Flutter package that provides loading functionality to a widget.
With Loader #
A Flutter package that provides loading functionality to a widget. Just Warp your widget with WithLoader
and give all the necessary parameters.
Features #
- Can be helpful when you need a
Future
function to be performedonTap
of a Button. - You can customise the
child
opacity while it is in loading state. - It exposes the result of the
Future
function, through which you can decide thesuccess
orfailure
condition of that function. - According to this
successCondition
it will performonSuccess
oronFailure
.
Getting started #
Add with_loader
to pubspec.yaml
of your project:
dependencies:
with_loader: ^0.0.1
Import it in your Dart code:
import 'package:with_loader/with_loader.dart';
Usage #
Wrap any widget with WithLoader<T>()
:
WithLoader<Type>(
child: AnyWidget()
),
Some required parameters
to make this widget work:
WithLoader<String>(
future: () => Future.delayed(const Duration(seconds: 2), () => "Success"),
successCondition: (result) => result == "Success",
child: Container(
decoration: BoxDecoration(
color: Colors.purple.shade400,
borderRadius: BorderRadius.circular(50),
),
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 32.0,
vertical: 16.0,
),
child: Text(
"Button",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
),
),