Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MaterialApp(
- theme: ThemeData(primarySwatch: Colors.blueGrey),
- home: PracticeApp(),
- ));
- }
- class PracticeApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.grey,
- appBar: AppBar(
- title: Text('PracticeApp'),
- centerTitle: true,
- ),
- body: Stack(
- children: [
- Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: NetworkImage(
- 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg'),
- fit: BoxFit.cover,
- ),
- ),
- ),
- CustomPaint(
- painter: HolePainter(),
- child: Container(),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(50),
- ),
- color: Colors.grey.shade600.withOpacity(0.8),
- ),
- padding: EdgeInsets.all(10.0),
- margin: EdgeInsets.all(20),
- child: IconButton(
- icon: Icon(Icons.flash_on),
- onPressed: null,
- ),
- ),
- Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(50),
- ),
- color: Colors.grey.shade600.withOpacity(0.8),
- ),
- padding: EdgeInsets.all(10.0),
- margin: EdgeInsets.all(20),
- child: IconButton(
- icon: Icon(Icons.photo_camera),
- onPressed: null,
- ),
- ),
- ],
- )
- ],
- ),
- );
- }
- }
- class HolePainter extends CustomPainter {
- @override
- void paint(Canvas canvas, Size size) {
- //print('${size.height},${size.width}');
- final paint = Paint();
- paint.color = Colors.grey.withOpacity(0.8);
- canvas.drawPath(
- Path.combine(
- PathOperation.difference,
- Path()
- ..addRRect(RRect.fromLTRBR(
- 0, 0, size.width, size.height, Radius.circular(0))),
- Path()
- ..addOval(Rect.fromCircle(
- center: Offset(size.width / 2, size.height / 2), radius: 180))
- ..close(),
- ),
- paint,
- );
- }
- @override
- bool shouldRepaint(CustomPainter oldDelegate) {
- return false;
- }
- }
Add Comment
Please, Sign In to add comment