sz_core 2.0.3 copy "sz_core: ^2.0.3" to clipboard
sz_core: ^2.0.3 copied to clipboard

retracted

SZ Core is a lightweight Flutter utility package that simplifies application development in one package.

SZ Core #

pub package

A lightweight Flutter package that provides reusable widgets, responsive sizing, utility methods, dialogs, navigation helpers, and a simple API caller to speed up Flutter application development.

Features #

  • ✅ Responsive UI scaling (.w, .h, .r, .sp)
  • ✅ Base Activity & Fragment architecture
  • ✅ Built-in API caller (GET,POST,PUT,PATCH & DELETE)
  • ✅ Toasts, dialogs & pickers
  • ✅ Navigation helper
  • ✅ Phone, Website & WhatsApp launcher
  • ✅ Keyboard helper
  • ✅ Date & Time formatting
  • ✅ Random Dark Color generator
  • ✅ Hex Color extension
  • ✅ Native Android & iOS device information
  • ✅ Application information
  • ✅ Dynamic User-Agent generation

Included Classes #

  • SZCore
  • SZActivity
  • SZFragment
  • SZApiCaller
  • SZApiSetting
  • SZShow
  • SZText
  • SZButton
  • SZIconButton
  • SZTextField

Installation #

Add the package to your pubspec.yaml.

dependencies:
  sz_core: ^2.0.3

Then run

flutter pub get

Import #

import 'package:sz_core/sz_core.dart';

Initialization #

Initialize SZCore before runApp().

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await SZCore.init();

  runApp(const MyApp());
}

With Base URL #

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await SZCore.init(
    baseURL: "https://example.com/api/",
  );

  runApp(const MyApp());
}

Custom API Settings #

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  SZApiSetting.init(
    "https://example.com/api/",
    keyStatus: "status",
    keyMessage: "message",
    keyData: "data",
    keyInternet: "internet", 
    defaultHeader: {
      "Authorization": "Bearer TOKEN"
    }
  );

  await SZCore.init();

  runApp(const MyApp());
}

You can update custom setting directly from anywhere like

SZApiSetting.defaultHeader = {
   "Authorization": "Bearer UPDATED TOKEN"
};

Device Information #

SZCore provides native device and application information through Android and iOS platform channels.

The DeviceInfo model contains application, operating system, device, and hardware information.

Get Device Information #

final deviceInfo = await SZCore.getDeviceInfo();

Example:

final deviceInfo = await SZCore.getDeviceInfo();

print(deviceInfo.appName);
print(deviceInfo.appVersion);
print(deviceInfo.appBuild);

print(deviceInfo.platform);
print(deviceInfo.osName);
print(deviceInfo.osVersion);

print(deviceInfo.model);
print(deviceInfo.manufacturer);
print(deviceInfo.brand);

DeviceInfo Properties #

Property Description
platform Platform name, e.g. Android or iOS
appName Application display name
appVersion Application version
appBuild Application build number
model Device model
manufacturer Device manufacturer
brand Device brand
device Android device code name
product Android product name
osName Operating system name
osVersion Operating system version
sdk Android SDK/API level
abis Supported CPU architectures
deviceName User-visible device name
identifier Platform-provided identifier

Example Output #

Android:

Platform      : Android
App Name      : My App
App Version   : 1.2.0
App Build     : 25
Manufacturer  : Samsung
Brand         : Samsung
Model         : SM-S928B
OS Name       : Android
OS Version    : 15
SDK           : 35
ABIs          : arm64-v8a

iOS:

Platform      : iOS
App Name      : My App
App Version   : 1.2.0
App Build     : 25
Model         : iPhone
OS Name       : iOS
OS Version    : 18.6

User-Agent #

SZCore can generate a dynamic User-Agent using the application and device information.

final headers = await SZCore.getDefaultHeader();

Example Android:

My App/1.2.0 (Android 15; Samsung SM-S928B; Build 25)

Example iOS:

My App/1.2.0 (iOS 18.6; iPhone; Build 25)

You can use the generated header with your API requests:

final headers = await SZCore.getDefaultHeader();

print(headers["User-Agent"]);

Responsive Size #

SZCore.init() automatically calculates the screen scale.

Use the extensions anywhere.

Container(
  width: 120.w,
  height: 60.h,
  padding: EdgeInsets.all(12.r),
  child: SZText(
    "Hello",
    fontSize: 16.sp,
  ),
)
Extension Description
.w Width scaling
.h Height scaling
.r Radius scaling
.sp Responsive font size

SZActivity #

Replace State with SZActivity.

Replace build() with buildContent().

class HomeActivity extends StatefulWidget {
  const HomeActivity({super.key});

  @override
  State<HomeActivity> createState() => _HomeActivityState();
}

class _HomeActivityState extends SZActivity<HomeActivity> {

  @override
  Widget buildContent(BuildContext context) {
    return const SizedBox();
  }
}

Available Methods #

showDialog("Loading...");

hideDialog();

open(const SecondActivity());

onResume();

onPaused();

SZFragment #

Replace State with SZFragment.

Replace build() with buildContent().

class HomeFragment extends StatefulWidget {
  const HomeFragment({super.key});

  @override
  State<HomeFragment> createState() => _HomeFragmentState();
}

class _HomeFragmentState extends SZFragment<HomeFragment> {

  @override
  Widget buildContent(BuildContext context) {
    return const SizedBox();
  }
}

Available Methods #

showDialog("Loading...");

hideDialog();

open(const SecondActivity());

onResume();

onPaused();

SZCore #

Open Activity #

Open a new activity:

await SZCore.open(
  context,
  const HomeActivity(),
);

Parameters #

Parameter Default Description
finish false Closes the current activity before opening the new activity.
onlyOne false Clears all previous activities and opens the new activity as the only active activity.

Example #

await SZCore.open(
  context,
  const HomeActivity(),
  finish: true,
  onlyOne: true,
);

Hide Keyboard #

SZCore.hideKeyboard(context);

Screen Size #

final size = await SZCore.getScreenSize();

 SZCore.printLog(size.width);
 SZCore.printLog(size.height);

Date Formatting #

Server format

SZCore.formattedDate(DateTime.now());

Output

2026-07-07

Display format

SZCore.formattedDate(
  DateTime.now(),
  server: false,
);

Output

7 Jul 2026

Time Formatting #

Server

SZCore.formattedTime(DateTime.now());

Output

14:30

Display

SZCore.formattedTime(
  DateTime.now(),
  server: false,
);

Output

2:30 PM

Random Dark Color #

Color color = SZCore.getRandomDarkColor();

Debug Log #

SZCore.printLog("Hello");

Prints only in Debug mode.


Open Phone Dialer #

SZCore.openCall("9876543210");

Open Website #

SZCore.openWebsite(
  "https://flutter.dev",
);

Open WhatsApp #

SZCore.openWhatsApp(
  "919876543210",
  message: "Hello",
);

Hex Color Extension #

Color color = "#2196F3".toColor();

SZShow #

Toast #

SZShow.toast("Saved Successfully");

Custom

SZShow.toast(
  "Error",
  bg: Colors.red,
  color: Colors.white,
  size: 14,
);

Dialog #

SZShow.dialog(
  context,
  "Success",
  "Data Saved Successfully",
);

Two Buttons

SZShow.dialog(
  context,
  "Delete",
  "Delete this record?",
  btn1: "Yes",
  btn2: "No",
  b1Click: () {

  },
  b2Click: () {

  },
);

Custom Widget

SZShow.dialog(
  context,
  "",
  "",
  buildContent: (setState) {
    return const Text("Custom Widget");
  },
);

Date Picker #

SPair date = await SZShow.dateSelect(
  context,
  null,
);

Time Picker #

SPair time = await SZShow.timeSelect(
  context,
  null,
);

Year Picker #

int year = await SZShow.yearSelect(
  context,
  2025,
);

Widgets #

SZText #

A customizable text widget with support for icons, required indicators, shadows, and responsive font sizing.

const SZText(
  'Welcome to SZ Core',
  fontSize: 16,
  fontWeight: FontWeight.bold,
);

const SZText(
  'Email Address',
  required: true,
  icon: Icons.email,
);

SZButton #

A customizable button with support for icons, colors, borders, and disabled states.

SZButton(
  text: 'Login',
  onClick: () {
    login();
  },
);

SZButton(
  text: 'Delete',
  icon: Icons.delete,
  btnColor: Colors.red,
  onClick: deleteItem,
);

SZIconButton #

A compact icon button with support for custom widgets and long-click actions.

SZIconButton(
  icon: Icons.edit,
  onClick: () {
    editProfile();
  },
);

SZIconButton(
  icon: Icons.delete,
  bgColor: Colors.red,
  onClick: deleteItem,
  onLongClick: showDeleteConfirmation,
);

SZTextField #

A customizable text field with support for icons, labels, password mode, and keyboard configuration.

SZTextField(
  hint: 'Enter your name',
  controller: nameController,
);

SZTextField(
  hint: 'Password',
  obscureText: true,
  suffixIcon: Icons.visibility,
);

SZDropDown #

A generic dropdown widget supporting any object type.

SZDropDown<Pair>(
  true,
  selectedCountry,
  countries,
  (value) {
    setState(() {
      selectedCountry = value;
    });
  },
  toStringConvert: (item) => item.name,
);

SZAutoComplete #

An autocomplete widget with asynchronous search support.

SZAutoComplete<Pair>(
  isEnable: true,
  value: selectedUser,
  onSearch: (keyword) async {
    return await searchUsers(keyword);
  },
  displayText: (item) => item.name,
  onSelected: (item) {
    selectedUser = item;
  },
);

SZApiCaller #

Supports both GET and POST requests.

GET Request #

SZApiCaller(
  context,
  this,
  1,
  null,
  "Loading...",
  "users",
).then((response, key) {

});

POST Request #

SZApiCaller(
  context,
  this,
  2,
  jsonEncode(data),
  "Please wait...",
  "login",
).then((response, key) {

});

PUT,PATCH,DELETE Request #

You can use below enum

enum SZMethod { get, post, delete, put, patch }
SZApiCaller(
  context,
  this,
  2,
  jsonEncode(data),
  "Please wait...",
  "login",
  method = SZMethod.put
).then((response, key) {

});

Custom Header #

SZApiCaller(
  context,
  this,
  1,
  null,
  null,
  "users",
  customHeader: {
    "Authorization": "Bearer TOKEN"
  },
).then((response, key) {

});

Logout Callback #

SZCore.logoutCallback = () {
  // Navigate to Login Screen
};

If the API response contains "session expire", the callback is automatically invoked.


Requirements #

  • Flutter SDK >= 3.0.0

Contributing #

Contributions, issues, and feature requests are welcome.


License #

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

2
likes
0
points
572
downloads

Publisher

verified publishersoftozin.com

Weekly Downloads

SZ Core is a lightweight Flutter utility package that simplifies application development in one package.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http, intl, plugin_platform_interface, url_launcher

More

Packages that depend on sz_core

Packages that implement sz_core