agnext_common_library_flutter 1.0.7 copy "agnext_common_library_flutter: ^1.0.7" to clipboard
agnext_common_library_flutter: ^1.0.7 copied to clipboard

Agnext common library to reuse various widgets and functions

example/lib/main.dart

import 'package:example/src/CommonBottomSheet.dart';
import 'package:example/src/CommonColors.dart';
import 'package:example/src/common_text_field.dart';
import 'package:example/src/custom_button.dart';
import 'package:example/src/dimensions.dart';
import 'package:example/src/widgets.dart';
import 'package:flutter/material.dart';

import 'main.dart';
export 'package:flutter_screenutil/flutter_screenutil.dart';
export 'package:get/get.dart' hide FormData, MultipartFile, Response;

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    //this is required to be add in  main dart file otherevise all dimension are not working and also this package use getx management packages you can modity if required
    return ScreenUtilInit(
        designSize: const Size(360, 690),
        minTextAdapt: true,
        splitScreenMode: true,
        builder: (_, child) {
          return GetMaterialApp(
            theme: new ThemeData(
              appBarTheme:
                  AppBarTheme(iconTheme: IconThemeData(color: Colors.black)),
            ),
            smartManagement: SmartManagement.onlyBuilder,
            debugShowCheckedModeBanner: false,
            locale: const Locale('en', 'US'),
            defaultTransition: Transition.rightToLeft,
            home: MyHomePage(
              title: "Home page",
            ),
          );
        });
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonWidgets.customAppBar(
          title: "custom app bar",
          actions: <Widget>[
            CommonWidgets.setPadding(
                rightPadding: margin_20,
                widget: Icon(
                  Icons.favorite,
                  color: CommonColors.white,
                )),
          ],
          appBarBGColor: CommonColors.primaryColor,
          appBarTitleColor: CommonColors.white),

      //add padding with just two lines of code
      body: CommonWidgets.setPaddingAll(
        margin: margin_20,
        widget: Column(
          children: [
            //use common text and easily add font size with minimal code
            CommonWidgets.commonText("this is commonWidget",
                fontSize: font_16, color: CommonColors.primaryColor),
            CommonWidgets.sizedBox(height: height_20),

            CommonWidgets.networkImages(
                "https://fastly.picsum.photos/id/230/200/300.jpg?hmac=pyhlpgJN2oBeEzhJbnJYrCsLoJM6MKd_NUQGIQhVx5k",
                height: height_200,
                width: width_170),

            CommonTextField.commonTextField(
              labelText: "username"
            ),

            CustomButton(
                buttonText: "open bottonSheet",
                onClick: () {
                  CommonBottomSheet.commonBottomSheet(
                      body: CommonWidgets.setPaddingAll(
                    margin: margin_20,
                    widget: Container(
                      width: CommonWidgets.fullWidth(context),
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Align(
                            alignment: Alignment.topLeft,
                            child: IconButton(
                              icon: Icon(Icons.close),
                              onPressed: () {
                                Get.back();
                              },
                            ),
                          ),
                          CommonWidgets.commonText("this is common Bottomsheet",
                              fontSize: font_16,
                              color: CommonColors.primaryColor),
                        ],
                      ),
                    ),
                  ));
                })
          ],
        ),
      ),
      // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}