Skip to content

Instantly share code, notes, and snippets.

View amirrezasalimi's full-sized avatar
🌍
Working

Amirreza salimi amirrezasalimi

🌍
Working
View GitHub Profile
@amirrezasalimi
amirrezasalimi / route-change.ts
Created August 27, 2022 09:22
nextjs prevent route change hook (typescript)
interface IRouteChangeProps {
routeChangeFn: () => boolean
}
const useRouteChange = (props: IRouteChangeProps) => {
const router = useRouter();
const routeChangeStart = () => {
const close_res = props.routeChangeFn();
if (!close_res) {
router.events.emit('routeChangeError', router.asPath, { shallow: true });
throw 'Abort route change. Please ignore this error.';
@amirrezasalimi
amirrezasalimi / main.dart
Created December 5, 2021 12:44
flutter custom slider
import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
scrollBehavior: AppScrollBehavior(),
@amirrezasalimi
amirrezasalimi / main.dart
Last active February 24, 2024 23:12
flutter toggle password animation v2
import 'package:flutter/material.dart';
//create by Amirreza salimi https://gist.github.com/amirrezasalimi/48132d9330f53672a894829961cb727b/
class ToggleInput extends StatefulWidget {
@override
ToggleInputState createState() => ToggleInputState();
}
class ToggleInputState extends State<ToggleInput>
with TickerProviderStateMixin {
bool isHidden = false;