neo_reusables 1.0.2 copy "neo_reusables: ^1.0.2" to clipboard
neo_reusables: ^1.0.2 copied to clipboard

A Dart package for all Neo's reusables. It features mostly wrappers on already implemented Flutter widgets and other constructs to help you write better code.

Neo Reusables #

This package contains most of the reusables I use when starting a fresh flutter project

Features #

Widget Reusables #

  • SizeConfig: Used for making sure your UI elements/widgets scale for every screen size
  • NeoText: A fancy wrapper around the normal Text widget. Improves the accessibility of the regular Text widget
  • NeoButton: Another wrapper class, allows developers to create flexible buttons
  • XMargin and YMargin: Provides spaces between elements, in a clear, concise way
  • Navigator: All your navigation needs in one place

Data Reusables #

  • Resource: A wrapper that contains the data model, status and error of any network operation done

Getting started #

You just need to import:

import 'package:neo_reusables/neo_reusables.dart';

Usage #

Note: The examples folder will provider more use-cases and more complex uses

Resource #

    //First create the Resource and specify the type, in this case UserModel will be our hypothetical model
    //Here, we'll set the resource to it's initial state, IDLE
    Resource<UserModel> resource = Resource.idle();

    //To show the loading state of your operation
    resource = Resource.loading();

    // To show the error state of your operation
    resource = Resource.failed("Error message goes here");

    //To show success state of your operation
    final UserModel userModel = UserModel.fromJson(json);
    resource = Resource.success(userModel);

SizeConfig #

  • First initialize the SizeConfig file in your main file like this:

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Builder(builder: (context) {
        final Size size = MediaQuery.of(context).size;
        SizeConfig.init(context,
            width: size.width, height: size.height, allowFontScaling: true);

        return const MyHomePage(title: 'Flutter Demo Home Page');
      }),
    );
  }
}

  • Then use it to generate scalable heights and widths like so

    final SizeConfig sizeConfig = SizeConfig();

    //Scalable height
    sizeConfig.sh(20).toDouble()

    //Scalable width
    sizeConfig.sw(20).toDouble()

NeoButton #

The onClick and text fields are required

    NeoButton(
        onClick: () {},
        text: 'Tap',
    )

NeoText #

The text field is required

    NeoText(
        text: "Your text",
    )

YMargin #

Provides vertical spacing in your UI

    YMargin(height: 10)

XMargin #

Provides horizontal spacing in your UI

    XMargin(height: 10)

1
likes
130
pub points
0%
popularity

Publisher

unverified uploader

A Dart package for all Neo's reusables. It features mostly wrappers on already implemented Flutter widgets and other constructs to help you write better code.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on neo_reusables