import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; import 'GlobalConstants.dart'; import 'app_colors.dart'; PreferredSizeWidget appbar(BuildContext context, title) { return AppBar( automaticallyImplyLeading: false, elevation: 2.0, title: SizedBox( child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ InkResponse( onTap: () => Navigator.pop(context, true), child: SvgPicture.asset("assets/svg/app_bar_back.svg", height: 25), ), InkResponse( onTap: () => Navigator.pop(context,true), child: Text( title, style: TextStyle( fontSize: 16, height: 1.1, fontFamily: "JakartaSemiBold", color: AppColors.semi_black, ), ), ), ], ), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(30), // Adjust the radius as needed ), ), ); } PreferredSizeWidget appbar2(BuildContext context, title,reset,widget) { return AppBar( automaticallyImplyLeading: false, elevation: 2.0, title: SizedBox( child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ InkResponse( onTap: (){ reset(); Navigator.pop(context, true); }, child: SvgPicture.asset("assets/svg/app_bar_back.svg", height: 25), ), Expanded( flex:4, child: InkResponse( onTap: () { reset(); Navigator.pop(context, true); }, child: Text( title, overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( fontSize: 16, height: 1.1, fontFamily: "JakartaSemiBold", color: AppColors.semi_black, ), ), ), ), Spacer(), widget ], ), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(30), // Adjust the radius as needed ), ), ); } Future onBackPressed(BuildContext context) async { Navigator.pop(context, true); return true; } Widget Emptywidget(BuildContext context){ return SizedBox( height: MediaQuery.of(context).size.height*0.8, child: Center( child: Text("No Data Available")), ); } Widget TextWidget(context, text) { return Padding( padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), child: Text(text), ); } Widget errorWidget(context, text) { if (text != null) return Text(text!, style: TextStyle(color: Colors.red, fontSize: 12)); else return SizedBox(height: 10); } Widget textControllerWidget( context, controller, hintText, Function(String)? onChanged, inputtype, readonly, inputFormatters, ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), child: Text(hintText), ), Container( height: hintText == "Enter Description" ? 150 : 50, alignment: Alignment.center, decoration: BoxDecoration( color: AppColors.text_field_color, borderRadius: BorderRadius.circular(14), ), child: Padding( padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0), child: TextFormField( controller: controller, readOnly: readonly, keyboardType: inputtype, maxLines: hintText == "Enter Description" ? 60 : 1, onChanged: onChanged, inputFormatters: inputFormatters != null ? [FilteringTextInputFormatter.digitsOnly] : [], decoration: InputDecoration( hintText: hintText, hintStyle: TextStyle( fontWeight: FontWeight.w400, color: Color(0xFFB4BEC0), fontSize: 14, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, ), ), ), ), ], ); } Widget textControllerReadonlyWidget( context, controller, hintText, Function(String)? onChanged, ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), child: Text(hintText), ), Container( height: hintText == "Enter Description" ? 150 : 50, alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFFE9E9E9), borderRadius: BorderRadius.circular(14), ), child: Padding( padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0), child: TextFormField( controller: controller, readOnly: true, keyboardType: TextInputType.text, maxLines: hintText == "Enter Description" ? 60 : 1, onChanged: onChanged, style: TextStyle(color: Color(0xFF818181), fontSize: 14), decoration: InputDecoration( hintText: hintText, hintStyle: TextStyle( fontWeight: FontWeight.w400, color: Color(0xFFB4BEC0), fontSize: 14, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, ), ), ), ), ], ); } class MyNavigatorObserver extends NavigatorObserver { @override void didPush(Route route, Route? previousRoute) { super.didPush(route, previousRoute); // Called when a route has been pushed onto the navigator. didPushed = "true"; // print('Route pushed: ${route.settings.name}'); // print('didPushed$didPushed'); } @override void didPop(Route route, Route? previousRoute) { super.didPop(route, previousRoute); didPopped = "true"; // Called when a route has been popped off the navigator. // print('Route popped: ${route.settings.name}'); // print('didPopped${didPopped}'); } }