dev_prokit 0.0.6 copy "dev_prokit: ^0.0.6" to clipboard
dev_prokit: ^0.0.6 copied to clipboard

dev_prokit is a package that provides developers with common functions in project development. It is comprehensive, easy to use, safe and reliable.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DevProkit Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const GapWidget(),
    );
  }
}

/// Quickly fill the space between widgets with a specified size.
class GapWidget extends StatelessWidget {
  const GapWidget({super.key});

  @override
  Widget build(BuildContext context) {
    /// 1. Gap Example
    """
    10.vGap  (int)
    5.2.vGap (double)
    """;

    /// 2. HEX、HEXA 、AHEX To Color
    """
    '#3bc'.color       (HEX)
    '#33bbcc'.color    (HEX)
    '#33bbccff'.color  (HEXA)
    '#ff33bbcc'.color  (AHEX)
    """;

    /// 3. Widget Edgeinset
    """
    // Widget
    Text('Hello Word').insets(EdgeInsets.zero)
    Text('Hello Word').insetsAll(10)
    Text('Hello Word').insetsOnly(left: 10)
    Text('Hello Word').insetsSymmetric(horizontal: 10, vertical: 20)
    
    // Sliver Widget
    SliverToBoxAdapter(child: Text('Hello Word')).insets(EdgeInsets.zero)
    SliverToBoxAdapter(child: Text('Hello Word')).insetsAll(10)
    SliverToBoxAdapter(child: Text('Hello Word')).insetsOnly(left: 10)
    SliverToBoxAdapter(child: Text('Hello Word')).insetsSymmetric(horizontal: 10, vertical: 20)
    
    // Sliver Subclass
    class PageBoxAdapter extends SliverToBoxAdapter {
      const PageBoxAdapter({super.key});
    }
    PageBoxAdapter().sliverInsets(EdgeInsets.zero)

    // More Methods
    insetsFromViewPadding
    insetsLTRB
    insetsLerp
    """;

    /// 4. TextStyle
    """
    TextStyle().fSize(18)
    TextStyle().fColor(Colors.red)
    TextStyle().bold
    TextStyle().fHeight(1.2)
    ......
    """;

    /// 5. Log
    """
    Dio dio = new Dio(baseOptions);
    dio.interceptors
      ..add(const LogDiyInterceptor(type: LogType.rich));
    """;

    /// 6. RangeNum
    """
    3.range(min:4); // 4
    3.0.range(max:2.0); // 2.0
    3.5.range(min:2.0, max:4.0); // 3.5
    """;

    /// 7. Event debounce
    """
    // No Parameters
    GestureDetector(
      onTap:() {
        print('Debounce without parameters method');
      }.debounce(),
      ......
    )

    // A Parameter
    InkWell(
      onTapDown: (details) {
        print('A Parameter');
      }.debounceParam(),
    }

    // Two Parameter
    PersonWidget(
      onRun:(name,time) {
        print('name-time');
      }.debounceParam2(),
    )

    // More than two parameters
    Function(String,(int,String)) diyOnRun = (name,(time,address)) {
      print('name-time-address');
    }.debounceParam2();

    PersonWidget(
      onRun:(name,time,address) {
        diyOnRun(name,(time,address));
      },
    )
    """;

    /// 8. Event Throttle
    """
    // No Parameters
    GestureDetector(
      onTap:() {
        print('throttle without parameters method');
      }.throttle(),
      ......
    )

    // A Parameter
    InkWell(
      onTapDown: (details) {
        print('A Parameter');
      }.throttleParam(),
    }

    // Two Parameter
    PersonWidget(
      onRun:(name,time) {
        print('name-time');
      }.throttleParam2(),
    )

    // More than two parameters
    Function(String,(int,String)) diyOnRun = (name,(time,address)) {
      print('name-time-address');
    }.throttleParam2();

    PersonWidget(
      onRun:(name,time,address) {
        diyOnRun(name,(time,address));
      },
    )
    """;

    /// 9. Generate random array quickly
    """
    RandomList.nextBool(3); // [true, false, true]
    RandomList.nextInt(3);  // [2, 0, 1]
    RandomList.nextInt(3, start:10); // [12, 10, 12]
    RandomList.nextInt(3, start:10, repeat:false); // [12, 10, 11]
    RandomList.nextDouble() 
    ...... etc.
    """;

    const TextStyle tStyle = TextStyle(fontFamily: 'Rc', height: 1);

    return Scaffold(
      appBar: AppBar(
        title: Text(
          '文本样式',
          style: tStyle.bold,
        ),
      ),
      body: Column(
        children: [
          Text(
            '设置字重',
            textDirection: TextDirection.rtl,
            style: tStyle.medium,
          ).insetsOnly(right: 200),
          Text(
            '设置大小',
            style: tStyle.fSize(20),
          ).insets(const EdgeInsetsDirectional.all(30)),
          Text(
            '设置文本颜色',
            style: tStyle.fColor(Colors.red),
          ),
          SizedBox(
            width: 60,
            child: Text(
              '设置溢出格式',
              textDirection: TextDirection.rtl,
              style: tStyle.oFlow(TextOverflow.ellipsis),
            ),
          ),
          Text(
            '设置文字字母间距',
            style: tStyle.lSpacing(5),
          ),
          Text(
            '设置文字字体间距ab like',
            style: tStyle.wSpacing(50),
          )
        ],
      ).insetsAll(20),
    );
  }
}

class MethodWidget extends StatelessWidget {
  const MethodWidget({super.key, this.itemMethod});
  final Function(String, int)? itemMethod;

  @override
  Widget build(BuildContext context) {
    return const Placeholder();
  }
}

class PageBoxAdapter extends SliverToBoxAdapter {
  const PageBoxAdapter({super.key});
}
9
likes
150
points
24
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

dev_prokit is a package that provides developers with common functions in project development. It is comprehensive, easy to use, safe and reliable.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter

More

Packages that depend on dev_prokit