some_widget_extensions

Creator: coderz1093

Last updated:

0 purchases

some_widget_extensions Image
some_widget_extensions Images

Languages

Categories

Add to Cart

Description:

some widget extensions

some_widget_extensions #
some_widget_extensions is a Dart library that provides a collection of convenient extensions for Flutter widgets, lists of widgets, and the BuildContext. These extensions help streamline widget composition and make Flutter code more readable and concise.
Features #

Utility extensions for BuildContext.
Extensions for lists of widgets to wrap them in common Flutter widgets.
Extensions for individual widgets to wrap them in common Flutter widgets.

Installation #
Add some_widget_extensions to your pubspec.yaml file:
dependencies:
some_widget_extensions: latest
copied to clipboard
Then, run pub get to install the package.
Usage #
Import the library:
import 'package:some_widget_extensions/some_widget_extensions.dart';
copied to clipboard
Example #
import 'package:flutter/material.dart';
import 'package:some_widget_extensions/some_widget_extensions.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Widget Extensions Example'),
),
body: [
Text('Hello'),
Text('World'),
]
.column(mainAxisSize: MainAxisSize.min)
.card()
),
);
}
}
copied to clipboard
API #
Utility Extensions on BuildContext #
The following extensions provide convenient access to common properties from the BuildContext.
ThemeData get theme
Obtains ThemeData from the current BuildContext.
final theme = context.theme;
copied to clipboard
MediaQueryData get media
Obtains MediaQueryData from the current BuildContext.
final media = context.media;
copied to clipboard
Extensions on List<Widget> #
The following extensions provide convenient methods to wrap lists of widgets in common Flutter widgets.
Column column({Key? key, MainAxisAlignment mainAxisAlignment, MainAxisSize mainAxisSize, CrossAxisAlignment crossAxisAlignment, TextDirection? textDirection, VerticalDirection verticalDirection, TextBaseline? textBaseline})
Wraps a list of widgets into a Column.
Column column({
Key? key,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
MainAxisSize mainAxisSize = MainAxisSize.max,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
})
copied to clipboard
Row row({Key? key, MainAxisAlignment mainAxisAlignment, MainAxisSize mainAxisSize, CrossAxisAlignment crossAxisAlignment, TextDirection? textDirection, VerticalDirection verticalDirection, TextBaseline? textBaseline})
Wraps a list of widgets into a Row.
Row row({
Key? key,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
MainAxisSize mainSize = MainAxisSize.max,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
})
copied to clipboard
Stack stack({Key? key, AlignmentGeometry alignment, TextDirection? textDirection, StackFit fit, Clip clipBehavior})
Wraps a list of widgets into a Stack.
Stack stack({
Key? key,
AlignmentGeometry alignment = AlignmentDirectional.topStart,
TextDirection? textDirection,
StackFit fit = StackFit.loose,
Clip clipBehavior = Clip.hardEdge,
})
copied to clipboard
Flex flex({Key? key, required Axis direction, MainAxisAlignment mainAxisAlignment, MainAxisSize mainAxisSize, CrossAxisAlignment crossAxisAlignment, TextDirection? textDirection, VerticalDirection verticalDirection, TextBaseline? textBaseline, Clip clipBehavior})
Wraps a list of widgets into a Flex.
Flex flex({
Key? key,
required Axis direction,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
MainAxisSize mainAxisSize = MainAxisSize.max,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
Clip clipBehavior = Clip.none,
})
copied to clipboard
ListView listView({Key? key, Axis scrollDirection, bool reverse, ScrollController? controller, bool? primary, ScrollPhysics? physics, bool shrinkWrap, EdgeInsetsGeometry? padding, double? itemExtent, double Function(int, SliverLayoutDimensions)? itemExtentBuilder, Widget? prototypeItem, bool addAutomaticKeepAlives, bool addRepaintBoundaries, bool addSemanticIndexes, double? cacheExtent, int? semanticChildCount, DragStartBehavior dragStartBehavior, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, String? restorationId, Clip clipBehavior})
Wraps a list of widgets into a ListView.
ListView listView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
double? itemExtent,
double Function(int, SliverLayoutDimensions)? itemExtentBuilder,
Widget? prototypeItem,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior =
ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
})
copied to clipboard
Extensions on Widget #
The following extensions provide convenient methods to wrap individual widgets in common Flutter widgets.
Card card({Key? key, Color? color, Color? shadowColor, Color? surfaceTintColor, double? elevation, ShapeBorder? shape, bool borderOnForeground, EdgeInsetsGeometry? margin, Clip? clipBehavior, bool semanticContainer})
Wraps a widget in a Card.
Card card({
Key? key,
Color? color,
Color? shadowColor,
Color? surfaceTintColor,
double? elevation,
ShapeBorder? shape,
bool borderOnForeground = true,
EdgeInsetsGeometry? margin,
Clip? clipBehavior,
bool semanticContainer = true,
})
copied to clipboard
SafeArea safeArea({Key? key, bool left, bool top, bool right, bool bottom, EdgeInsets minimum, bool maintainBottomViewPadding})
Wraps a widget in a SafeArea.
SafeArea safeArea({
Key? key,
bool left = true,
bool top = true,
bool right = true,
bool bottom = true,
EdgeInsets minimum = EdgeInsets.zero,
bool maintainBottomViewPadding = false,
})
copied to clipboard
Padding padding({Key? key, required EdgeInsetsGeometry padding})
Wraps a widget in Padding.
Padding padding({
Key? key,
required EdgeInsetsGeometry padding,
})
copied to clipboard
SizedBox sizedBox({Key? key, double? width, double? height})
Wraps a widget in a SizedBox.
SizedBox sizedBox({
Key? key,
double? width,
double? height,
})
copied to clipboard
Container container({Key? key, AlignmentGeometry? alignment, EdgeInsetsGeometry? padding, Color? color, Decoration? decoration, Decoration? foregroundDecoration, double? width, double? height, BoxConstraints? constraints, EdgeInsetsGeometry? margin, Matrix4? transform, AlignmentGeometry? transformAlignment, Clip clipBehavior})
Wraps a widget in a Container.
Container container({
Key? key,
AlignmentGeometry? alignment,
EdgeInsetsGeometry? padding,
Color? color,
Decoration? decoration,
Decoration? foregroundDecoration,
double? width,
double? height,
BoxConstraints? constraints,
EdgeInsetsGeometry? margin,
Matrix4? transform,
AlignmentGeometry? transformAlignment,
Clip clipBehavior = Clip.none,
})
copied to clipboard
Expanded expanded({Key? key, int flex})
Wraps a widget in Expanded.
Expanded expanded({
Key? key,
int flex = 1,
})
copied to clipboard
ClipRect clipRect({Key? key, CustomClipper<Rect>? clipper, Clip clipBehavior})
Wraps a widget in a ClipRect.
ClipRect clipRect({
Key? key,
CustomClipper<Rect>? clipper,
Clip clipBehavior = Clip.hardEdge,
})
copied to clipboard
ClipRRect clipRRect({Key? key, BorderRadiusGeometry borderRadius, CustomClipper<RRect>? clipper, Clip clipBehavior})
Wraps a widget in a ClipRRect.
ClipRRect clipRRect({
Key? key,
BorderRadiusGeometry borderRadius = BorderRadius.zero,
CustomClipper<RRect>? clipper,
Clip clipBehavior = Clip.antiAlias,
})
copied to clipboard
ClipOval clipOval({Key? key, CustomClipper<Rect>? clipper, Clip clipBehavior})
Wraps a widget in a ClipOval.
ClipOval clipOval({
Key? key,
CustomClipper<Rect>? clipper,
Clip clipBehavior = Clip.antiAlias,
})
copied to clipboard
ClipPath clipPath({Key? key, CustomClipper<Path>? clipper, Clip clipBehavior})
Wraps a widget in a ClipPath.
ClipPath clipPath({
Key? key,
CustomClipper<Path>? clipper,
Clip clipBehavior = Clip.antiAlias,
})
copied to clipboard
InkWell inkWell({Key? key, void Function()? onTap, void Function()? onDoubleTap, void Function()? onLongPress, void Function(TapDownDetails)? onTapDown, void Function(TapUpDetails)? onTapUp, void Function()? onTapCancel, void Function()? onSecondaryTap, void Function(TapUpDetails)? onSecondaryTapUp, void Function(TapDownDetails)? onSecondaryTapDown, void Function()? onSecondaryTapCancel, void Function(bool)? onHighlightChanged, void Function(bool)? onHover, MouseCursor? mouseCursor, Color? focusColor, Color? hoverColor, Color? highlightColor, MaterialStateProperty<Color?>? overlayColor, Color? splashColor, InteractiveInkFeatureFactory? splashFactory, double? radius, BorderRadius? borderRadius, ShapeBorder? customBorder, bool? enableFeedback, bool excludeFromSemantics, FocusNode? focusNode, bool canRequestFocus, void Function(bool)? onFocusChange, bool autofocus, MaterialStatesController? statesController})
Wraps a widget in an InkWell.
InkWell inkWell({
Key? key,
void Function()? onTap,
void Function()? onDoubleTap,
void Function()? onLongPress,
void Function(TapDownDetails)? onTapDown,
void Function(TapUpDetails)? onTapUp,
void Function()? onTapCancel,
void Function()? onSecondaryTap,
void Function(TapUpDetails)? onSecondaryTapUp,
void Function(TapDownDetails)? onSecondaryTapDown,
void Function()? onSecondaryTapCancel,
void Function(bool)? onHighlightChanged,
void Function(bool)? onHover,
MouseCursor? mouseCursor,
Color? focusColor,
Color? hoverColor,
Color? highlightColor,
MaterialStateProperty<Color?>? overlayColor,
Color? splashColor,
InteractiveInkFeatureFactory? splashFactory,
double? radius,
BorderRadius? borderRadius,
ShapeBorder? customBorder,
bool? enableFeedback = true,
bool excludeFromSemantics = false,
FocusNode? focusNode,
bool canRequestFocus = true,
void Function(bool)? onFocusChange,
bool autofocus = false,
MaterialStatesController? statesController,
})
copied to clipboard
SingleChildScrollView singleChildScrollView({Key? key, Axis scrollDirection, bool reverse, EdgeInsetsGeometry? padding, bool? primary, ScrollPhysics? physics, ScrollController? controller, DragStartBehavior dragStartBehavior, Clip clipBehavior, String? restorationId, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior})
Wraps a widget in a SingleChildScrollView.
SingleChildScrollView singleChildScrollView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
EdgeInsetsGeometry? padding,
bool? primary,
ScrollPhysics? physics,
ScrollController? controller,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Clip clipBehavior = Clip.hardEdge,
String? restorationId,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior =
ScrollViewKeyboardDismissBehavior.manual,
})
copied to clipboard
Align align({Key? key, AlignmentGeometry alignment, double? widthFactor, double? heightFactor})
Wraps a widget in an Align.
Align align({
Key? key,
AlignmentGeometry alignment = Alignment.center,
double? widthFactor,
double? heightFactor,
})
copied to clipboard
Positioned positioned({Key? key, double? left, double? top, double? right, double? bottom, double? width, double? height})
Wraps a widget in a Positioned.
Positioned positioned({
Key? key,
double? left,
double? top,
double? right,
double? bottom,
double? width,
double? height,
})
copied to clipboard
Center center({Key? key, double? widthFactor, double? heightFactor})
Wraps a widget in a Center.
Center center({
Key? key,
double? widthFactor,
double? heightFactor,
})
copied to clipboard
Notes on Usage #
This package employs an opinionated style of building UI that leverages extensions for wrapping widgets. While this approach offers convenience and can make your code more concise, it may not be suitable for everyone. Here are a few considerations:


Opinionated Style: This package encourages a specific way of composing Flutter widgets. If you prefer a more traditional, declarative syntax for building your UI, this package might not be for you. It’s important to consider the coding style and conventions of your project or team.


Consistency in Style: Mixing and matching this extension-based style with traditional declarative syntax could lead to inconsistent code styling. For the sake of maintainability and readability, it's recommended to stick with one approach rather than combining both.


Contributing: We welcome contributions! If you have more extensions that you’d like to see included in this package, feel free to raise an issue or submit a pull request on GitHub. Your feedback and contributions help improve the package for everyone.


Thank you for considering some_widget_extensions for your Flutter projects! We hope it helps streamline your development process and makes your code more readable and maintainable.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.