Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Created December 26, 2022 19:14
Show Gist options
  • Save felipecastrosales/708b1b87a6ac94ed1c33ffa796d014cc to your computer and use it in GitHub Desktop.
Save felipecastrosales/708b1b87a6ac94ed1c33ffa796d014cc to your computer and use it in GitHub Desktop.
overlay size
import 'package:flutter/material.dart';
class OverlayImage extends StatelessWidget {
const OverlayImage({super.key});
@override
Widget build(BuildContext context) {
return Material(
type: MaterialType.transparency,
child: SafeArea(
child: Stack(
children: [
Container(
alignment: Alignment.center,
color: Colors.red,
padding: const EdgeInsets.all(20),
child: InkWell(
onTap: () {
debugPrint('Image tapped');
Navigator.pop(context);
},
child: const OverlayImage2(),
),
),
Positioned(
top: 20,
right: 20,
child: IconButton(
icon: const Icon(Icons.close_rounded),
color: Colors.white,
onPressed: () => Navigator.pop(context),
),
),
],
),
),
);
}
}
class OverlayImage2 extends StatelessWidget {
const OverlayImage2({super.key});
@override
Widget build(BuildContext context) {
return Image.network(
'https://picsum.photos/1080/1080',
fit: BoxFit.contain,
height: double.infinity,
width: double.infinity,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment