nex_all_plugin 0.0.3 copy "nex_all_plugin: ^0.0.3" to clipboard
nex_all_plugin: ^0.0.3 copied to clipboard

A comprehensive Flutter package that combines all Nexever utilities including device checks, file picking, social authentication, toast messages, validation, pagination, logging, and API handling.

Nex All Plugin #

A comprehensive Flutter plugin that provides multiple utility features including pagination, API calls, toast notifications, logging, file picking, device security checks, form validation, and social authentication.

Features #

🚀 Core Features #

  • Pagination Widget - Easy-to-use pagination with pull-to-refresh
  • Common API Methods - Simplified GET/POST API calls
  • Toast Notifications - Customizable toast messages with multiple styles
  • Logging System - Colored console logging with different log levels
  • File Picker - Document and file selection with callbacks
  • Device Security - Check for USB debugging, VPN, rooting, and debugger
  • Form Validation - Email, phone, name, and password validation
  • Social Login - Google, Facebook, and Apple authentication

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  nex_all_plugin: ^0.0.2

Setup #

Firebase Configuration #

For social login features, configure Firebase in your project:

  1. Add your google-services.json (Android) and GoogleService-Info.plist (iOS) files
  2. Update firebase_option.dart with your Firebase configuration:
import 'package:firebase_core/firebase_core.dart';
import 'dart:io' show Platform;

class DefaultFirebaseOptions {
  static FirebaseOptions get currentPlatform {
    if (Platform.isAndroid) {
      return android;
    } else if (Platform.isIOS) {
      return ios;
    } else {
      throw UnsupportedError(
        'DefaultFirebaseOptions are not supported for this platform.',
      );
    }
  }

  static const FirebaseOptions android = FirebaseOptions(
    apiKey: "YOUR_API_KEY",
    appId: "YOUR_APP_ID",
    messagingSenderId: "YOUR_SENDER_ID",
    projectId: "YOUR_PROJECT_ID",
    storageBucket: "YOUR_STORAGE_BUCKET",
    databaseURL: "YOUR_DATABASE_URL",
  );

  static const FirebaseOptions ios = FirebaseOptions(
    apiKey: "YOUR_IOS_API_KEY",
    appId: "YOUR_IOS_APP_ID", 
    messagingSenderId: "YOUR_SENDER_ID",
    projectId: "YOUR_PROJECT_ID",
    storageBucket: "YOUR_STORAGE_BUCKET",
    iosClientId: "YOUR_IOS_CLIENT_ID",
    iosBundleId: "YOUR_BUNDLE_ID",
    databaseURL: "YOUR_DATABASE_URL",
  );
}

Main App Setup #

Initialize Firebase and wrap your app with OKToast:

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:nex_all_plugin/nex_all_plugin.dart';
import 'firebase_option.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  runApp(
    OKToast(
      child: MaterialApp(
        home: YourApp(),
      ),
    ),
  );
}

Usage #

1. Pagination Widget #

Create paginated lists with pull-to-refresh functionality:

class PaginationExample extends StatefulWidget {
  @override
  State<PaginationExample> createState() => _PaginationExampleState();
}

class _PaginationExampleState extends State<PaginationExample> {
  List<String> items = List.generate(20, (index) => 'Item ${index + 1}');
  final int totalItems = 100;

  void fetchMoreItems() {
    setState(() {
      int currentLength = items.length;
      int itemsToAdd = (totalItems - currentLength).clamp(0, 20);
      items.addAll(List.generate(
        itemsToAdd, (index) => 'Item ${currentLength + index + 1}',
      ));
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PaginationWidget(
        paginationFunction: fetchMoreItems,
        total: totalItems,
        current: items.length,
        paginate: true,
        child: ListView.builder(
          itemCount: items.length,
          itemBuilder: (context, index) {
            return ListTile(title: Text(items[index]));
          },
        ),
      ),
    );
  }
}

2. API Methods #

Simplify your HTTP requests:

class ApiExample extends StatefulWidget {
  @override
  _ApiExampleState createState() => _ApiExampleState();
}

class _ApiExampleState extends State<ApiExample> {
  ApiMethods apiMethods = ApiMethods();
  String response = '';

  // GET Request
  void getData() async {
    try {
      var result = await apiMethods.getMethod(
        url: 'https://jsonplaceholder.typicode.com/posts/1',
        headers: {"Accept": "application/json"},
      );
      
      setState(() {
        response = jsonEncode({
          "status": result.$1,
          "data": result.$2,
        });
      });
    } catch (e) {
      setState(() {
        response = 'Error: $e';
      });
    }
  }

  // POST Request
  void postData() async {
    try {
      var result = await apiMethods.postMethod(
        url: 'https://jsonplaceholder.typicode.com/posts',
        body: jsonEncode({'title': 'foo', 'body': 'bar', 'userId': 1}),
      );
      
      setState(() {
        response = jsonEncode({
          "status": result.$1,
          "data": result.$2,
        });
      });
    } catch (e) {
      setState(() {
        response = 'Error: $e';
      });
    }
  }
}

3. Toast Notifications #

Display customizable toast messages:

class MyToast extends ToastFile {
  void showSuccessToast() {
    toastMsg(
      msg: "Success! Operation completed successfully.",
      backgroundColor: Colors.green,
      position: ToastPosition.bottom,
      duration: const Duration(seconds: 2),
      textStyle: TextStyle(
        fontSize: 16.0,
        color: Colors.white,
        fontWeight: FontWeight.bold,
      ),
      radius: 10.0,
      textMaxLines: 2,
      textAlign: TextAlign.center,
    );
  }

  void showErrorToast() {
    toastMsg(
      msg: "Error! Something went wrong.",
      backgroundColor: Colors.red,
      position: ToastPosition.bottom,
      duration: const Duration(seconds: 3),
      textStyle: TextStyle(
        fontSize: 16.0,
        color: Colors.white,
        fontWeight: FontWeight.bold,
      ),
    );
  }
}

4. Logging System #

Use colored console logging:

// Different log levels
logMessage(text: 'This is a simple log message');
logError('This is an error log message', error: 'Error details here');
logWarning('This is a warning log message', error: 'Warning details here');
logSuccess('This is a success log message');

5. File Picker #

Pick files with callbacks:

class FilePickerExample extends StatefulWidget {
  @override
  State<FilePickerExample> createState() => _FilePickerExampleState();
}

class _FilePickerExampleState extends State<FilePickerExample>
    implements NexFilePickerState {
  
  late FilePickerHelper filePickerHelper;
  String selectedFile = 'No file selected';

  @override
  void initState() {
    super.initState();
    filePickerHelper = FilePickerHelper(this);
  }

  @override
  void success({ReturnModel? fileData, String? type}) {
    setState(() {
      selectedFile = fileData?.fileName ?? 'Unknown file';
    });
    logSuccess('File selected: $selectedFile');
  }

  @override
  void error(dynamic error) {
    logError('File picker error', error: error.toString());
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          ElevatedButton(
            onPressed: () {
              filePickerHelper.openAttachmentDialog(fileType: "document");
            },
            child: Text('Pick Document'),
          ),
          Text('Selected: $selectedFile'),
        ],
      ),
    );
  }
}

6. Device Security Checks #

Check device security status:

class SecurityCheckExample extends StatefulWidget {
  @override
  State<SecurityCheckExample> createState() => _SecurityCheckExampleState();
}

class _SecurityCheckExampleState extends State<SecurityCheckExample> {
  bool isUsbDebugging = false;
  bool isVpnConnected = false;
  bool isDeviceRooted = false;
  bool isDebugger = false;

  @override
  void initState() {
    super.initState();
    checkSecurity();
  }

  Future<void> checkSecurity() async {
    try {
      isUsbDebugging = await NexeverCheckPlugin.isUsbDebuggingEnabled;
      isVpnConnected = await NexeverCheckPlugin.isVpnConnected;
      isDeviceRooted = await NexeverCheckPlugin.isDeviceRooted;
      isDebugger = await NexeverCheckPlugin.isDebuggerConnected;
      
      setState(() {});
    } catch (e) {
      logError('Security check failed', error: e.toString());
    }
  }
}

7. Form Validation #

Validate user inputs:

import 'package:nex_validation/nex_validation.dart';

class ValidationExample extends StatefulWidget {
  @override
  State<ValidationExample> createState() => _ValidationExampleState();
}

class _ValidationExampleState extends State<ValidationExample> {
  final _nameController = TextEditingController();
  final _emailController = TextEditingController();
  String? _nameError;
  String? _emailError;

  void _validateForm() {
    setState(() {
      _nameError = _nameController.text.nameValidations(
        min: 3,
        emptyMsg: 'Name cannot be empty',
        lengthMsg: 'Name must be between 3 and 20 characters',
        validMsg: 'Name contains invalid characters',
      );

      _emailError = _emailController.text.emailValidations(
        emptyMsg: 'Email address cannot be empty',
        validMsg: 'Invalid email address format',
      );
    });
  }
}

8. Social Login #

Implement social authentication:

class AuthController implements LoginState {
  final Function(UserCredential, String)? onSuccess;
  final Function(String)? onError;

  AuthController({this.onSuccess, this.onError});

  @override
  void error(error) {
    onError?.call(error.toString());
  }

  @override
  void success(UserCredential creds, String loginType) {
    onSuccess?.call(creds, loginType);
  }

  // Google Login
  googleLogin() async {
    LoginManager(loginMethod: GoogleLogin(), loginState: this).login();
  }

  // Facebook Login
  facebookLogin() {
    LoginManager(loginMethod: FaceBookLogin(), loginState: this).login();
  }

  // Apple Login
  appleLogin() {
    LoginManager(loginMethod: AppleLogin(), loginState: this).login();
  }
}

Toast Positions #

Available toast positions:

  • ToastPosition.top
  • ToastPosition.center
  • ToastPosition.bottom

Validation Methods #

Available validation methods:

  • nameValidations(min, max, emptyMsg, lengthMsg, validMsg)
  • emailValidations(emptyMsg, validMsg)
  • phoneNumberValidations(emptyMsg, minLengthMsg, maxLengthMsg)
  • passwordValidations(min, max, emptyMsg, minLengthMsg, maxLengthMsg)

File Types #

Supported file picker types:

  • "document" - For document files
  • "image" - For image files

Security Checks #

Available security check methods:

  • NexeverCheckPlugin.isUsbDebuggingEnabled
  • NexeverCheckPlugin.isVpnConnected
  • NexeverCheckPlugin.isDeviceRooted
  • NexeverCheckPlugin.isDebuggerConnected

Log Types #

Available logging methods:

  • logMessage(text: 'message') - General information
  • logError('message', error: 'details') - Error messages
  • logWarning('message', error: 'details') - Warning messages
  • logSuccess('message') - Success messages

Social Login Providers #

Supported authentication providers:

  • Google Sign-In
  • Facebook Login
  • Apple Sign-In

Requirements #

  • Flutter 3.32.0 or higher
  • Dart 3.8.0 or higher
  • Firebase project (for social login features)

Platform Support #

  • ✅ Android
  • ✅ iOS

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog #

Version 0.0.1 #

  • Initial release
  • Added pagination widget
  • Added API methods
  • Added toast notifications
  • Added logging system
  • Added file picker
  • Added device security checks
  • Added form validation
  • Added social login

Support #

For support, email dileep.nexever@gmail.com or create an issue on GitHub.

0
likes
150
points
19
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter package that combines all Nexever utilities including device checks, file picking, social authentication, toast messages, validation, pagination, logging, and API handling.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, nex_common_api, nex_common_logs, nex_common_pagination, nex_common_toast, nex_validation, nexever_check_plugin, nexever_file_picker, nexever_social_auth

More

Packages that depend on nex_all_plugin