Created
June 27, 2018 05:33
-
-
Save manujbahl/d0ffaa1607f3b4ae8758bbae7378e469 to your computer and use it in GitHub Desktop.
InkWell samples
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'; | |
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