Created
March 13, 2020 14:34
-
-
Save IkhwanSI13/ca121e84b5c096b5a15a7dfebbb4d780 to your computer and use it in GitHub Desktop.
Contoh pass function to another widget
This file contains 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'; | |
import 'package:ikanas/style/Colors.dart'; | |
class ExampleActivity extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: ColorWhite, | |
resizeToAvoidBottomPadding: true, | |
body: BaseButton(onClickLogin), | |
); | |
} | |
onClickLogin() { | |
// do something | |
} | |
} | |
class BaseButton extends StatelessWidget { | |
final void Function() callbackClick; | |
BaseButton(this.callbackClick); | |
@override | |
Widget build(BuildContext context) { | |
return InkWell( | |
onTap: () { | |
callbackClick(); | |
}, | |
child: Container( | |
width: 48, | |
height: 48, | |
child: Text("Click me"), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment