Last active
February 16, 2022 19:55
-
-
Save internetova/62ddd22f2dabbbb5e67f1bfaf77f5017 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'; | |
void main() { | |
runApp( | |
MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: HomePage(), | |
), | |
); | |
} | |
/// Нажми на картинку! | |
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Home Page'), | |
), | |
body: Center( | |
child: Stack( | |
children: <Widget>[ | |
Image.network( | |
'https://picsum.photos/1000/600?random=1'), | |
Positioned.fill( | |
child: Material( | |
type: MaterialType.transparency, | |
child: InkWell( | |
splashColor: Colors.yellow[200], | |
onTap: () { | |
print('Клик по фото'); | |
}, | |
), | |
), | |
), | |
Positioned( | |
bottom: 0, | |
child: Text( | |
'Привет! Я сверху 🤓', | |
style: Theme.of(context).textTheme.headline3?.copyWith(color: Colors.red), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Виктор Дунаев, [28 дек. 2020 г., 2:16:13]:
Вместо color: Colors.transparent используйте type: MaterialType.transparency.
Разница между ними в том, что второй ничего не рисует, а первый рисует ничего (хоть и ничего, но рисует, т.е. производит операцию наложения цвета).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dartpad.dev/62ddd22f2dabbbb5e67f1bfaf77f5017?null_safety=true