nb_utils 4.2.8 copy "nb_utils: ^4.2.8" to clipboard
nb_utils: ^4.2.8 copied to clipboard

outdated

This package helps you daily usable function with ease. Just add nb_utils with its latest version and that's it you are ready to use.

Show some love and like to support the project #

Intro #

This package helps you daily usable function with ease. Just add nb_utils with its latest version and that's it you are ready to use.

Documentation #

API Docs are available.

Installation #

add this line to pubspec.yaml


   dependencies:
     nb_utils: <latest_version>

import package


    import 'package:nb_utils/nb_utils.dart';

initialize nb_utils in main.dart file


    await initialize();

Examples #

Widgets Extensions, Methods #

  /// With custom height and width
    Container().withSize();

    /// With custom width
    Container().withWidth(25);

    /// With custom height
    Container().withHeight(100);

    /// return padding top
    Container().paddingTop(2);

    /// return padding left
    Container().paddingLeft(4);

    /// return padding right
    Container().paddingRight(8);

    /// return padding bottom
    Container().paddingBottom(16);

    /// return padding all
    Container().paddingAll(8);

    /// return custom padding from each side
    Container().paddingOnly();

    /// return padding symmetric
    Container().paddingSymmetric();

    /// set visibility
    /// true/false
    Container().visible(true);

    /// add custom corner radius each side
    Container().cornerRadiusWithClipRRectOnly(topLeft: 10, bottomRight: 12);

    /// add corner radius
    Container().cornerRadiusWithClipRRect(20);

    /// set widget visibility
    /// true/false
    Container().withVisibility(true);

    /// add opacity to parent widget
    Container().opacity(opacity: 0.2);

    /// add rotation to parent widget
    Container().rotate(angle: 1.2);

    /// add scaling to parent widget
    Container().scale(scale: 2.0);

    /// set parent widget in center
    Container().center();

    /// add tap to parent widget
    /// Add this to widget make it that
    Container().onTap(() {
      //
    });

    /// Wrap with ShaderMask widget
    Container().withShaderMask([Colors.black, Colors.red]);

    /// Wrap with ShaderMask widget Gradient
    Container().withShaderMaskGradient(LinearGradient(colors: [Colors.black, Colors.red]));

    /// add Expanded to parent widget
    Container().expand();

    /// add Flexible to parent widget
    Container().flexible();

    /// add FittedBox to parent widget
    Container().fit();

    /// Validate given widget is not null and returns given value if null.
    Container().validate();

    /// Validate given widget is not null and returns given value if null.
    Container().withTooltip(msg: "Hello");


Time formatter Extensions, Methods #

    /// returns how much time ago from timestamp
    /// The number of milliseconds that have passed since the timestamp
    int difference = DateTime.now().millisecondsSinceEpoch;

    /// Converts the time difference to a number of seconds.
    countSeconds(difference);

    /// Converts the time difference to a number of minutes.
    countMinutes(difference);

    /// Converts the time difference to a number of hours.
    countHours(difference);

    /// Converts the time difference to a number of days.
    countDays(difference);

    /// Converts the time difference to a number of weeks.
    countWeeks(difference);

    /// Converts the time difference to a number of months.
    countMonths(difference);

    /// Converts the time difference to a number of years.
    countYears(difference);


Strings Extensions, Methods #

  /// Returns True/False

    String example = "";

    /// Check URL validation
    example.validateURL();

    /// Check email validation
    example.validateEmail();

    /// Check phone validation
    example.validatePhone();

    /// Return true if given String is Digit
    example.isDigit();

    /// Check weather String is alpha or not
    example.isAlpha();

    /// Check weather String is Json or not
    example.isJson();

    /// Copy String to Clipboard
    example.copyToClipboard();

    /// for ex. add comma in price
    example.formatNumberWithComma();

    /// Get Color from HEX String
    example.toColor();

    /// It reverses the String
    example.reverse;

    /// It return list of single character from String
    example.toList();

    /// Returns true if given String is null or isEmpty
    example.isEmptyOrNull;

    /// Check null string, return given value if null
    example.validate();

    /// Capitalize First letter of a given String
    example.capitalizeFirstLetter();

    ///returns if its type image
    example.isImage;

    ///returns if its type Audio
    example.isAudio;

    ///returns if its type Video
    example.isVideo;

    ///returns if its type Txt
    example.isTxt;

    ///returns if its type Doc
    example.isDoc;

    ///returns if its type Excel
    example.isExcel;

    ///returns if its type PPT
    example.isPPT;

    ///returns if its type Apk
    example.isApk;

    ///returns if its type Pdf
    example.isPdf;

    ///returns if its type Html
    example.isHtml;

    /// Pass the Pattern

    /// Splits from a [pattern] and returns remaining String after that
    example.splitAfter(Patterns.apk);

    /// Splits from a [pattern] and returns String before that
    example.splitBefore(Patterns.audio);

    /// It matches the String and returns between [startPattern] and [endPattern]
    example.splitBetween("d", "g");

    /// Return int value of given string
    example.toInt();

    /// Get YouTube Video ID
    example.toYouTubeId();

    /// Returns YouTube thumbnail for given video id
    example.getYouTubeThumbnail();

    /// Removes white space from given String
    example.removeAllWhiteSpace();

    /// Returns only numbers from a string
    example.getNumericOnly(example);

    /// Return average read time duration of given String in seconds
    example.calculateReadTime();

    /// Return number of words in a given String
    example.countWords();

    /// Generate slug of a given String
    example.toSlug();

    /// returns searchable array for Firebase Database
    example.setSearchParam();


Scroll Controller #

  ScrollController scrollController = ScrollController();
      
    /// animate to top
    scrollController.animToTop();
    /// animate to Bottom
    scrollController.animToBottom();
    /// animate to specific position 
    scrollController.animateToPosition(20.0);
    /// jump to the start of the list without animation
    scrollController.jumpToTop();
    /// jump to the end of the list without animation
    scrollController.jumpToBottom();



LiveStream & Shared Preferences #


    /// Declare the LIVESTREAM 
    
    LiveStream().on("streamName", (true) {
        //Your Logic
    });    
    
    /// EMIT THE LIVESTREAM
    LiveStream().emit("StreamName", true);

    /// Shared Preferences

    /// initiliaze the Method in main file
    await initialize();

    /// add a Double in SharedPref
    /// set method has {String key, String value} this parameter
    setDoubleAsync("Name", 20.0);

    /// add a Bool in SharedPref
    setBoolAsync("Name", false);

    /// add a Int in SharedPref
    setIntAsync("Name", 10);

    /// add a String in SharedPref
    setStringAsync("Name", "value");

    /// add a JSON in SharedPref
    setJSONAsync("Name", "Json Array");

    /// Returns a Bool if exists in SharedPref
    /// you can set a default value if its returns true or null
    getBoolAsync("name", defaultValue: "");

    /// Returns a Double if exists in SharedPref
    getDoubleAsync("name", defaultValue: "");

    /// Returns a Int if exists in SharedPref
    getIntAsync("name", defaultValue: "");

    /// Returns a String if exists in SharedPref
    getStringAsync("name", defaultValue: "");

    /// Returns a JSON if exists in SharedPref
    getJSONAsync("name", defaultValue: "");



TextStyles/Decorations/FocusNodes/Navigations/Toast/Context Methods #

 
    /// Apply Bold TextStyle
    Text(item.title.validate(), style: boldTextStyle())
    
    /// Apply Primary TextStyle
    Text(item.title.validate(), style: primaryTextStyle())
    
    /// Apply Secondary TextStyle
    Text(item.title.validate(), style: secondaryTextStyle())


    /// types of decoration
    Decoration decorationWithShadow = boxDecorationWithShadow();
    Decoration decorationWithRoundedCorners = boxDecorationWithRoundedCorners();

    /// boxDecorationRoundedWithShadow(RadiusAll)
    Decoration decorationRoundedWithShadow = boxDecorationRoundedWithShadow(10);

    /// default Box Shadow
    defaultBoxShadow(spreadRadius: 0, blurRadius: 0, shadowColor: Colors.red);

     /// Focusnode 
     requestFocus(NODE_VARIABLE);        
     nextFocus(NODE_VARIABLE);

    /// NAVIGATIONS Between Screen

    /// Open a new screen
    HomePage().launch(context);

    /// Remove all screens from back stack and opens new screen
    HomePage().launch(context, isNewTask: true);

    // Returns to previous Screen
    finish(context);


    ///  Handle error and loading widget when using FutureBuilder or StreamBuilder
    /// "snap" is the snapShot value we get from FutureBuilder or StreamBuilder
    snapWidgetHelper(snap)
    
    ///  Returns true is snapshot is loading
    isSnapshotLoading(snap)


    /// Toast a String
    toast('This is a string');

    /// Toast a String for a long duration
    toastLong('This is a string');

    /// Prints only if in debug or profile mode - (parameter is Object)
    log('Your string');

     /// return screen width
    context.width();

    /// return screen height
    context.height();
    
    /// Theme color or value from context
     context.primaryColor;
     context.theme.text.subtitle.color;  

DateTime Extensions, Methods #

 /// return current time in milliseconds
    int currentMillisecondTimeStamp = currentMillisecondsTimeStamp();

    /// return current timestamp
    int currentTimeStamps = currentTimeStamp();

    /// return true if given year is an leap year
    /// leapYear(year)
    bool isLeapYear = leapYear(2000);

    /// returns number of days in given month
    /// daysInMonth(monthNum, year)
    int dayInMonthTotal = daysInMonth(2, 2000);

    /// Returns Time Ago
    /// only on datetime object
    /// justNow, 2 minutes ago, 1 hour ago, 1 day ago

    String timeAgo = DateTime.now().timeAgo;


Systems Methods #

     /// Change status bar Color and Brightness
    setStatusBarColor(Colors.blue);
    
    /// Show Status Bar
    showStatusBar();

    /// Hide Status Bar
    hideStatusBar();

    /// Set orientation to portrait
    setOrientationPortrait();

    /// Set orientation to landscape
    setOrientationLandscape();

    /// Get current PlatformName as a String
    platformName();

    /// Invoke Native method and get result
    invokeNativeMethod(CHANNEL_NAME, METHOD_NAME, [dynamic arguments]);

Some Useful widgets #

    /// Add a Google Logo
    /// Add size parameter for custom size
    /// Default is 24
    GoogleLogoWidget()

    /// AppBar widget 
    appBarWidget(
      "Title",
      showBack: true,
      actions: [
        IconButton(
          icon: Icon(Icons.search),
          onPressed: () {},
        )
      ],
     )  
         
    //SettingItem 
     SettingItemWidget(
        title: "Title",
        onTap: () {
            //Your Logic
        },
        trailing: Icon(Icons.home_sharp),
        leading: Icon(Icons.arrow_forward_ios_rounded),
        subTitle: "Subtitle",
     ) 
     
    /// Default AppButton
    AppButton(
      text: "Submit",
      color: Colors.red,
      onTap: () {
      yout logic
      },
    ),

     Container(
       decoration: boxDecorationDefault(),
       height: 100,
       width: 100,
     ),
     UL(
        symbolType: SymbolType.Numbered,
        children: [
            Text('Hi', style: primaryTextStyle()),
            Text('Hello', style: primaryTextStyle()),
            Text('How are you?', style: primaryTextStyle()),
        ],
     ),
    
     AppTextField(
        controller: TextEditingController(),
        textFieldType: TextFieldType.EMAIL,
        decoration: InputDecoration(labelText: 'Email', border: OutlineInputBorder()),
     ),

     AppTextField(
        controller: TextEditingController(),
        textFieldType: TextFieldType.ADDRESS,
        decoration: InputDecoration(labelText: 'Address', border: OutlineInputBorder()),
     ),

     AppTextField(
        controller: TextEditingController(),
        textFieldType: TextFieldType.PASSWORD,
        decoration: InputDecoration(labelText: 'Password', border: OutlineInputBorder()),
     ),

     SettingSection(
      title: Text('Account Management', style: boldTextStyle(size: 24)),
      subTitle: Text('Control your account', style: primaryTextStyle(size: 16)),
      items: [
        SettingItemWidget(
          title: 'Hibernate account',
          subTitle: 'Temporary deactivate your account',
          decoration: BoxDecoration(borderRadius: radius()),
          trailing: Icon(Icons.keyboard_arrow_right_rounded, color: context.dividerColor),
          onTap: () {
            //HomePage().launch(context);
          }),
          SettingItemWidget(
            title: 'Close account',
            subTitle: 'Learn about your options, and close your account if you wish',
            decoration: BoxDecoration(borderRadius: radius()),
            trailing: Icon(Icons.keyboard_arrow_right_rounded, color: context.dividerColor),
            onTap: () {
                    //HomePage().launch(context);
            },
              ),
        ],
    ),


If you want to give suggestion, please contact me via email - bhoominn@gmail.com #

Thank you :) #

373
likes
0
pub points
99%
popularity

Publisher

verified publisherbhoominn.com

This package helps you daily usable function with ease. Just add nb_utils with its latest version and that's it you are ready to use.

Homepage

License

unknown (LICENSE)

Dependencies

connectivity, flutter, fluttertoast, shared_preferences

More

Packages that depend on nb_utils