Skip to content

Instantly share code, notes, and snippets.

@erluxman
Created July 5, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erluxman/1e102548403db046872d7db530e73594 to your computer and use it in GitHub Desktop.
Save erluxman/1e102548403db046872d7db530e73594 to your computer and use it in GitHub Desktop.
doughdemo.dart
import 'package:dough/dough.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DoughRecipe(
data: DoughRecipeData(
adhesion: 8,
viscosity: 2000,
),
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'ShaderMask Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Dough Demo'),
),
body: CircularBorderImageDemo(),
floatingActionButton: PressableDough(
child: Container(
width: 70,
height: 70,
child: FittedBox(
child: FloatingActionButton(
onPressed: () {},
child: Text(
"🧠",
style: TextStyle(fontSize: 40),
),
),
),
),
),
);
}
}
class CircularBorderImageDemo extends StatefulWidget {
@override
_CircularBorderImageDemoState createState() =>
_CircularBorderImageDemoState();
}
class _CircularBorderImageDemoState extends State<CircularBorderImageDemo> {
bool isPressed = false;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: GestureDetector(
onLongPressStart: (details) {
setState(() {
//isPressed = true;
});
},
onLongPressEnd: (details) {
setState(() {
isPressed = false;
});
},
onTapDown: (details) {
setState(() {
//isPressed = true;
});
},
onTapUp: (details) {
setState(() {
isPressed = false;
});
},
child: PressableDough(
child: AnimatedContainer(
height: isPressed ? 200 : 450,
width: isPressed ? 200 : 250,
curve: Curves.decelerate,
duration: Duration(milliseconds: isPressed ? 200 : 500),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(200),
border: Border.all(
color: isPressed ? Colors.pink : Colors.indigoAccent,
width: isPressed ? 8 : 6),
boxShadow: [
BoxShadow(
color: Color(isPressed ? 0x22222222 : 0x55222222),
blurRadius: isPressed ? 0 : 12,
spreadRadius: isPressed ? 0 : 12,
offset: Offset.fromDirection(0, 0)),
]),
child: ClipRRect(
borderRadius: BorderRadius.circular(400),
child: Image.network(
"https://akns-images.eonline.com/eol_images/Entire_Site/201949/rs_634x1024-190509150312-634-ed-sheearn-headshot.jpg",
fit: BoxFit.cover,
),
),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment