Created
April 17, 2021 13:52
-
-
Save eric-taix/96be7e21f410eb71e94f5e862ba86a40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
alignment: Alignment.center, | |
children: [ | |
CustomPaint( | |
size: Size(100, 100), | |
painter: BackgroundPainter(), | |
), | |
Container( | |
width: 90, height: 90, | |
decoration: BoxDecoration( | |
shape: BoxShape.circle, | |
), | |
child: Material( | |
color: Colors.green, | |
child: InkWell( | |
onTap: () {}, | |
child: Container( | |
child: Icon(Icons.ac_unit), | |
), | |
), | |
), | |
), | |
], | |
); | |
} | |
} | |
class BackgroundPainter extends CustomPainter { | |
@override | |
void paint(Canvas canvas, Size size) { | |
Paint paint = Paint() | |
..color = Colors.red | |
..style = PaintingStyle.fill; | |
Path path = Path() | |
..moveTo(0,0) | |
..lineTo(size.width, 0) | |
..lineTo(size.width, size.height) | |
..lineTo(0, size.height) | |
..close(); | |
canvas.drawPath(path, paint); | |
} | |
@override | |
bool shouldRepaint(covariant CustomPainter oldDelegate) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment