flutter_pro_tools 2.4.2 copy "flutter_pro_tools: ^2.4.2" to clipboard
flutter_pro_tools: ^2.4.2 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();
  await NotificationManager.setFirebaseProjectConfig(
      apiKey: 'apiKey',
      appId: 'appId',
      messagingSenderId: 'messagingSenderId',
      projectId: 'projectId');
  if (!kIsWeb) {
    await NotificationManager.initFlutterNotifications();
    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);
    var languageState = ref.read(languageStatus.notifier);
    SocketIoManagement.initConnection(socketURL: 'socketURL');
    checkForUpdate(appVersion: "2.3.0");
    return Scaffold(
      appBar: AppBar(title: ResponsiveText('home')),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  Size? screenSize = DeviceTools.screenSize;
                  if (screenSize != null) {
                    logFile(
                        message:
                            "Width: ${screenSize.width}, Height: ${screenSize.height}");
                  }
                },
                child: ResponsiveText("current_size"),
              ),
              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,
                  );
                },
                child: ResponsiveText("open_bar_model"),
              ),
              ElevatedButton(
                onPressed: () {
                  FlutterProTools.showMaterialModel(
                    const ModelPage(),
                  );
                },
                child: ResponsiveText("open_material_model"),
              ),
              ElevatedButton(
                onPressed: () {
                  SocketIoManagement.get(
                    event: 'event',
                    callback: (data) {
                      logFile(message: "$data");
                    },
                  );
                  SocketIoManagement.post(
                    event: 'event',
                    data: {"name": "my name"},
                  );
                },
                child: ResponsiveText("send_data_to_socket"),
              ),
              ElevatedButton(
                onPressed: () {
                  SocketIoManagement.withAck(
                    event: 'event',
                    data: {"name": "my name"},
                    callback: (data) {
                      logFile(message: data.toString(), name: 'my 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");
                  String? username =
                      await DataStorageTools.getString(key: "username");
                  ShowMessage.alert(
                    title: "Local Storage",
                    content: ResponsiveText(
                      translateText: false,
                      "${getTranslate("saved_username")}: $username",
                    ),
                  );
                },
                child: ResponsiveText("save_and_retrieve_local_data"),
              ),
              ElevatedButton(
                onPressed: () async {
                  ref.watch(languageStatus).locale.languageCode == "en"
                      ? languageState.changeLanguage('ar')
                      : languageState.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 {
                  FileManagement.chooseFile(
                      fileType: FileManagementType.camera);
                },
                child: ResponsiveText("open_camera"),
              ),
              ElevatedButton(
                onPressed: () async {
                  FileManagement.chooseFile(fileType: FileManagementType.image);
                },
                child: ResponsiveText("image_picker"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}