Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
InkWell samples
import 'package:flutter/material.dart';
main() {
runApp(new TestSample());
}
class TestSample extends StatelessWidget{
@override
Widget build(BuildContext context) {
var widget = new MaterialApp(
home: new Scaffold(
body: new Center(
child: new OuterContainerStack(),
)
),
);
return widget;
}
}
class OuterContainerStack extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Stack(
children: <Widget>[
new OuterContainer(),
new Positioned.fill(
child: new Material(
color: Colors.transparent,
child:new InkWell(
onTap: () {
print("Outer Container");
}
)
)
)
],
);
}
}
class OuterContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Container(
width: 300.0,
height: 300.0,
color: Colors.blueAccent,
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new InnerContainerStack()
],
),
);
}
}
class InnerContainerStack extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Stack(
children: <Widget>[
new InnerContainer(),
new Positioned.fill(
child: new Material(
color: Colors.transparent,
child:new InkWell(
onTap: () {
print("Inner Container");
}
)
)
)
],
);
}
}
class InnerContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Container(
width: 200.0,
height: 200.0,
color: Colors.redAccent
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment