netrunner_extensions 0.0.2

SDKflutter
Platformandroidioswindowslinuxmacosweb

A collection of useful Flutter extensions to ease development.

Netrunner Extensions

Netrunner Extensions is a Flutter extension library that provides a set of handy, reusable, and customizable widgets, intended to speed up app development. It's easy to use, efficient, and powerful.

Getting Started

To use this package, add netrunner_extensions as a dependency in your pubspec.yaml file.

Features

This package includes the following features:

  • Padding and Margin extensions.
  • Expanded and Flexible extensions.
  • Center and Align extensions.
  • Positioned extension.
  • Space extension.
  • Validate extension.

Usage

You can use the extensions in your Flutter application as follows:

import 'package:flutter/material.dart';
import 'package:netrunner_extensions/netrunner_extensions.dart';

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

class MyApp extends StatelessWidget {
  final GlobalKey<FormState> formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Form(
          key: formKey,
          child: Column(
            children: [
              // Padding Extension
              Container(
                color: Colors.red,
              ).paddingAll(10), // Applies 10 padding to all sides

              10.horizontalSpace, // Creates a horizontal space of 10

              Container(
                color: Colors.green,
              ).paddingSymmetric(vertical: 10, horizontal: 20), // Applies 10 padding to top & bottom, 20 to left & right

              // Margin Extension
              Container(
                color: Colors.blue,
              ).marginAll(10), // Applies 10 margin to all sides

              10.verticalSpace, // Creates a vertical space of 10

              Container(
                color: Colors.yellow,
              ).marginSymmetric(vertical: 10, horizontal: 20), // Applies 10 margin to top & bottom, 20 to left & right

              // Expanded Extension
              Container(
                color: Colors.orange,
              ).expanded(flex: 2), // Takes 2/3 of the available space

              // Flexible Extension
              Container(
                color: Colors.purple,
              ).flexible(flex: 1), // Takes remaining 1/3 of the available space

              // Center Extension
              Container(
                color: Colors.indigo,
              ).center, // Centers the container

              // Align Extension
              Container(
                color: Colors.teal,
              ).align(Alignment.bottomRight), // Aligns the container to the bottom right

              // Positioned Extension
              Stack(
                children: [
                  Container(
                    color: Colors.grey,
                  ).positioned(
                    top: 10,
                    right: 10,
                  ), // Positions the container 10 from the top and right within a stack
                ],
              ),

              // Validate Extension
              TextFormField(
                validator: (value) {
                  return value!.isEmpty ? 'Please enter some text' : null;
                },
              ), // A text form field
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            if (formKey.isValid) {
              print('Form is valid');
            } else {
              print('Form is not valid');
            }
          },
          child: Icon(Icons.check),
        ), // A button that checks whether the form is valid
      ),
    );
  }
}

Contributions

Contributions to the project are welcome! If you find a bug or think of a feature that should be added, please open an issue. If you would like to contribute code, feel free to open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more information.