Skip to content

Instantly share code, notes, and snippets.

@manujbahl
Created June 27, 2018 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manujbahl/d0ffaa1607f3b4ae8758bbae7378e469 to your computer and use it in GitHub Desktop.
Save manujbahl/d0ffaa1607f3b4ae8758bbae7378e469 to your computer and use it in GitHub Desktop.
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