Skip to content

Instantly share code, notes, and snippets.

@diegoveloper
Created April 30, 2020 16:25
Show Gist options
  • Select an option

  • Save diegoveloper/7f80d6e0c9e5ebd3e5e2986ea6fdd57a to your computer and use it in GitHub Desktop.

Select an option

Save diegoveloper/7f80d6e0c9e5ebd3e5e2986ea6fdd57a to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool clipped = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: GestureDetector(
onTap: () {
setState(() {
clipped = !clipped;
});
},
child: Center(
child: ClipRect(
clipper: clipped ? MyClipper() : null,
child: Image.network(
'https://aspgems.com/wp-content/uploads/2020/01/flutter-dart.png',
fit: BoxFit.cover,
),
),
),
)),
);
}
}
class MyClipper extends CustomClipper<Rect> {
@override
Rect getClip(Size size) {
return Rect.fromLTWH(size.height / 2, 0.0, size.height, size.height);
}
@override
bool shouldReclip(CustomClipper<Rect> oldClipper) => true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment