Last updated:
0 purchases
neo reusables
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';
copied to clipboard
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);
copied to clipboard
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');
}),
);
}
}
copied to clipboard
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()
copied to clipboard
NeoButton #
The onClick and text fields are required
NeoButton(
onClick: () {},
text: 'Tap',
)
copied to clipboard
NeoText #
The text field is required
NeoText(
text: "Your text",
)
copied to clipboard
YMargin #
Provides vertical spacing in your UI
YMargin(height: 10)
copied to clipboard
XMargin #
Provides horizontal spacing in your UI
XMargin(height: 10)
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.