flutter_pro_tools 2.8.1 copy "flutter_pro_tools: ^2.8.1" to clipboard
flutter_pro_tools: ^2.8.1 copied to clipboard

is a Flutter package that provides a collection of utilities and tools to help streamline your development process.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pro_tools/flutter_pro_tools.dart';
import 'package:flutter_pro_tools_example/login_page.dart';
import 'package:flutter_pro_tools_example/model_page.dart';
import 'package:flutter_pro_tools_example/new_page.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if (!kIsWeb) {
    // active this code to init flutter notifications
    // await NotificationManager.initFlutterNotifications(
    //   apiKey: 'apiKey',
    //   appId: 'appId',
    //   messagingSenderId: 'messagingSenderId',
    //   projectId: 'projectId',
    // );
    NotificationManager.firebaseMessaging(
      callback: (message) {
        prettyLogFile(message: message.toJson());
      },
    );
  }
  await DeviceTools.setDeviceOrientation();
  runApp(const ProviderScope(child: MyApp()));
}

class MyApp extends ConsumerWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    var state = ref.watch(languageStatus);
    return MaterialApp(
      navigatorKey: navigatorGlobalKey,
      scaffoldMessengerKey: snackBarGlobalKey,
      title: 'App name',
      home: const HomePage(),
      locale: state.locale,
      supportedLocales: AppLocale.supportedLocale(),
      localeResolutionCallback: AppLocale.localeResolutionCallback,
      localizationsDelegates: AppLocale.localizationsDelegates(),
    );
  }
}

class HomePage extends ConsumerWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    ref.watch(languageStatus);
    SocketIoManagement.initConnection(socketURL: 'http://192.168.1.12:3000');
    checkForUpdate(appVersion: "2.4.12");
    logFile(
      message: getDateFormatByDate(DateTime.now()),
      name: "date time now",
    );
    return Scaffold(
      appBar: AppBar(title: ResponsiveText('home')),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  makeCall("+963983442389");
                },
                child: ResponsiveText("make_call_phone"),
              ),
              ElevatedButton(
                onPressed: () {
                  logFile(message: convertToArabicWords(1234));
                  ShowMessage.success(message: convertToArabicWords(1234));
                },
                child: ResponsiveText("number_to_words"),
              ),
              ElevatedButton(
                onPressed: () {
                  ShareService.shareLink(link: "https://google.com");
                },
                child: ResponsiveText("shareable_link"),
              ),
              ElevatedButton(
                onPressed: () {
                  Size? screenSize = DeviceTools.screenSize;
                  if (screenSize != null) {
                    logFile(
                      message:
                          "Width: ${screenSize.width}, Height: ${screenSize.height}",
                    );
                  }
                },
                child: ResponsiveText("current_size"),
              ),
              ElevatedButton(
                onPressed: () {
                  LocationManagement.getPositionStream((onPositionUpdate) {
                    logFile(
                      message:
                          "my current position is ${onPositionUpdate.latitude},${onPositionUpdate.longitude}",
                    );
                  });
                },
                child: ResponsiveText("my_location"),
              ),
              ElevatedButton(
                onPressed: () {
                  LocationManagement.stopPositionStream();
                },
                child: ResponsiveText("stop_location"),
              ),
              ElevatedButton(
                onPressed: () {
                  NotificationManager.showNotification(
                    title: "hello title",
                    body: "hello body",
                    otherData: {
                      "title": "payload title",
                      "body": "payload body",
                    },
                    callback: (data) {
                      prettyLogFile(message: data.toJson());
                    },
                  );
                },
                child: ResponsiveText("display_notification"),
              ),
              ElevatedButton(
                onPressed: () {
                  logFile(message: LanguageManagement.getCurrentLanguage);
                },
                child: ResponsiveText("get_current_language"),
              ),
              ElevatedButton(
                onPressed: () {
                  FlutterProTools.showBarModal(
                    page: const ModelPage(),
                    enableDrag: true,
                    isDismissible: true,
                    callback: (data) {},
                  );
                },
                child: ResponsiveText("open_bar_model"),
              ),
              ElevatedButton(
                onPressed: () {
                  FlutterProTools.showMaterialModel(
                    const ModelPage(),
                    callback: (data) {},
                  );
                },
                child: ResponsiveText("open_material_model"),
              ),
              ElevatedButton(
                onPressed: () {
                  SocketIoManagement.get(
                    event: 'event',
                    callback: (data) {
                      logFile(message: "$data", name: "my socket log");
                    },
                  );
                  SocketIoManagement.post(
                    event: 'event',
                    data: {"name": "my name"},
                  );
                },
                child: ResponsiveText("send_data_to_socket"),
              ),
              ElevatedButton(
                onPressed: () {
                  SocketIoManagement.withAck(
                    event: 'ack_event',
                    data: {"name": "my name"},
                    callback: (data) {
                      logFile(
                        message: data.toString(),
                        name: 'my ack socket log',
                      );
                    },
                  );
                },
                child: ResponsiveText("send_ack_data_to_socket"),
              ),
              ElevatedButton(
                onPressed: () {
                  NavigationTools.push(const NewPage());
                },
                child: ResponsiveText("navigate_to_new_page"),
              ),
              ElevatedButton(
                onPressed: () {
                  FlutterProTools.showLoadingDialog();
                  Future.delayed(const Duration(seconds: 2), () {
                    FlutterProTools.dismissLoadingDialog();
                    ShowMessage.success(
                      message: getTranslate("loading_completed"),
                    );
                  });
                },
                child: ResponsiveText("show_loading_dialog"),
              ),
              ElevatedButton(
                onPressed: () {
                  ApiRequest.get(
                    url: "https://jsonplaceholder.typicode.com/posts/1",
                    response: (data) => ShowMessage.alert(
                      title: "GET Request",
                      content: ResponsiveText(data.body),
                    ),
                  );
                },
                child: ResponsiveText("perform_get_request"),
              ),
              ElevatedButton(
                onPressed: () async {
                  await DataStorageTools.storeString(
                    key: "username",
                    value: "JohnDoe",
                  );
                  await DataStorageTools.storeListOfString(
                    key: 'list',
                    value: ["1", "2", "3"],
                  );
                  await DataStorageTools.storeInteger(key: 'int', value: 1);
                  await DataStorageTools.storeDouble(key: 'double', value: 1);
                  await DataStorageTools.storeBoolean(key: 'bool', value: true);
                  await DataStorageTools.storeObjectOfString(
                    key: 'map',
                    value: {
                      "name": "userName",
                      "lastName": 1,
                      "age": {"number": 5},
                    },
                  );
                  String username = await DataStorageTools.getString(
                    key: "username",
                  );
                  List<String> list = await DataStorageTools.getListOfString(
                    key: 'list',
                  );
                  Map<String, dynamic> map =
                      await DataStorageTools.getObjectOfString(key: 'map');
                  int intValue = await DataStorageTools.getInteger(key: 'int');
                  bool boolValue = await DataStorageTools.getBoolean(
                    key: 'bool',
                  );
                  double doubleValue = await DataStorageTools.getDouble(
                    key: 'double',
                  );
                  logFile(message: list.toString(), name: 'list of string');
                  logFile(message: map.toString(), name: 'map');
                  logFile(message: intValue.toString(), name: 'int');
                  logFile(message: boolValue.toString(), name: 'bool');
                  logFile(message: doubleValue.toString(), name: 'double');
                  ShowMessage.alert(
                    title: "Local Storage",
                    content: ResponsiveText(
                      "${getTranslate("saved_username")}: $username",
                    ),
                  );
                },
                child: ResponsiveText("save_and_retrieve_local_data"),
              ),
              ElevatedButton(
                onPressed: () async {
                  ref.watch(languageStatus).locale.languageCode == "en"
                      ? LanguageManagement.changeLanguage('ar')
                      : LanguageManagement.changeLanguage('en');
                },
                child: ResponsiveText("change_language"),
              ),
              ElevatedButton(
                onPressed: () async {
                  NavigationTools.push(const LoginPage());
                },
                child: ResponsiveText('go_to_login_page'),
              ),
              ElevatedButton(
                onPressed: () async {
                  DataStorageTools.removeByKey(key: 'username');
                },
                child: ResponsiveText("remove_local_data"),
              ),
              ElevatedButton(
                onPressed: () async {
                  DataStorageTools.removeAll();
                },
                child: ResponsiveText("remove_all_data"),
              ),
              ElevatedButton(
                onPressed: () async {
                  FileManagement.chooseFile(
                    fileType: FileManagementType.camera,
                  );
                },
                child: ResponsiveText("open_camera"),
              ),
              ElevatedButton(
                onPressed: () async {
                  FileManagement.chooseFile(fileType: FileManagementType.image);
                },
                child: ResponsiveText("image_picker"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}