Skip to content

Instantly share code, notes, and snippets.

@IkhwanSI13
Created March 13, 2020 14:34
Show Gist options
  • Save IkhwanSI13/ca121e84b5c096b5a15a7dfebbb4d780 to your computer and use it in GitHub Desktop.
Save IkhwanSI13/ca121e84b5c096b5a15a7dfebbb4d780 to your computer and use it in GitHub Desktop.
Contoh pass function to another widget
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