Skip to main content

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

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

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:sz_core/sz_core.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SZCore.init();
  SZApiSetting.init(
    "",
    keyStatus: "status", //default status
    keyMessage: "message", //default message
    keyData: "data", //default data
    keyInternet: "internet", //default internet
  );

  printLog(SZCore.formattedTime(DateTime.timestamp(), server: false));
  printLog(SZCore.formattedTime(DateTime.timestamp()));
  printLog((await SZCore.getDeviceInfo()).toString());
  printLog((await SZCore.getDefaultHeader()).toString());
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int count = 0;
  String text = "";

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

  SPair? _date;
  SPair? _time;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        // scaffoldBackgroundColor: Colors.transparent,
        fontFamily: 'sarif',
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple),
        primaryColorLight: Colors.black,
        // colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent.shade700,
        //   primary: Colors.blueAccent.shade700,
        //   secondary: Colors.blueAccent.shade700,),
        appBarTheme: const AppBarTheme(
          backgroundColor: Colors.purple,
          // Light toolbar color
          iconTheme: IconThemeData(color: Colors.white),
          // Toolbar icon color
          titleTextStyle: TextStyle(color: Colors.white, fontSize: 20),
        ),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text('Plugin example app')),
        body: Builder(
          builder: (context) {
            return SingleChildScrollView(
              padding: EdgeInsets.all(10),
              child: Column(
                spacing: 10,
                children: [
                  InkWell(
                    onTap: () async {
                      var a = await SZCore.getScreenSize();
                      text = "${a.height}X${a.width}";
                      setState(() {
                        count++;
                      });
                      SZShow.toast("Test $count");
                    },
                    child: Text('COUNT : $count\n\n$text'),
                  ),
                  SZTextField(
                    hint: "Test",
                    bgColor: Colors.black,
                    borderWidth: 0.1,
                    suffixIcon: Icons.lock,
                    height: 38.h,
                  ),
                  SZAutoComplete(
                    onSearch: (keyword) async {
                      return [Pair(1, "HI")];
                    },
                    displayText: (item) => item.name,
                  ),
                  SZButton(
                    text: "Select Date",
                    onClick: () async {
                      var d = await SZShow.dateSelect(context, _date);
                      if (d != null) {
                        _date = d;
                      }
                    },
                  ),
                  SZButton(
                    text: "Select Time",
                    onClick: () async {
                      var d = await SZShow.timeSelect(context, _time);
                      if (d != null) {
                        _time = d;
                      }
                    },
                  ),
                ],
              ),
            );
          },
        ),
      ),
    );
  }
}
2
likes
160
points
313
downloads

Documentation

API reference

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

MIT (license)

Dependencies

flutter, http, intl, plugin_platform_interface, url_launcher

More

Packages that depend on sz_core

Packages that implement sz_core