nb_utils 4.2.5 copy "nb_utils: ^4.2.5" to clipboard
nb_utils: ^4.2.5 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 #


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

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

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

    /// Back to previous screen
    finish(context);

    /// Get Color from hex string
    Color color = getColorFromHex('#FFFFF');
    
    /// Hide soft keyboard
    hideKeyboard(context);
    
    /// Padding All, Apply TextStyle
    Column(
      children: <Widget>[
         Text(item.title.validate(), style: boldTextStyle()),
      ],
    ).paddingAll(16)
    
    /// Check given String is not null
    /// validate() function verifies weather given String is null or not. if null then it returns blank String
    /// validate() function prevents null object
    Text(item.title.validate()),
      
    /// 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())
    
    /// Rounded Image
    Image.network(item.image, height: 250).cornerRadiusWithClipRRect(20)
    
    /// Show a Widget (for ex here Circular Progress Bar) only if data is loading or doing some background task
    Loader().visible(mIsLoading)
    * mIsLoading is bool variable.
    
    /// Center Widget
    Text('Centered Text').center()

    /// Click on ANY Widget
    Container(
      height: 100,
    ).onTap(() {
      /// Handle Click
    })
    
    ///expand any widget
     Container(
      height: 100,
    ).expand()

    /// Check Email Validation
    if(!emailController.text.validateEmail()) { 
      /// Handle Email not valid
    } 
    
    /// Check Phone Number Validation
    if(!phoneController.text.validatePhone()) {
      /// Handle Phone Number not valid
    }
    
    /// AppBar widget 
    appBarWidget(
      "Title",
      showBack: true,
      actions: [
        IconButton(
          icon: Icon(Icons.search),
          onPressed: () {},
        )
      ],
     )  
     
    ///  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)

    
    //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
      },
    ),


   ///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();


    /// Find type of the the string
    /// Returns True/False 
    String typeString = "";

    ///returns if its type image
    typeString.isImage;
    ///returns if its type Audio
    typeString.isAudio;
    ///returns if its type Video
    typeString.isVideo;
    ///returns if its type Txt
    typeString.isTxt;
    ///returns if its type Doc
    typeString.isDoc;
    ///returns if its type Excel
    typeString.isExcel;
    ///returns if its type PPT
    typeString.isPPT;
    ///returns if its type Apk
    typeString.isApk;
    ///returns if its type Pdf
    typeString.isPdf;
    ///returns if its type Html
    typeString.isHtml;

     /// Focusnode 
     requestFocus(NODE_VARIABLE);        
     nextFocus(NODE_VARIABLE);
    /// 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;

    /// 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);

    /// Capitalize First Letter
    'this is simple string'.capitalizeFirstLetter();

    /// 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');

    /// 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]);

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

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

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