Created
May 29, 2020 05:09
-
-
Save vinceramcesoliveros/9e9fdeff8b820881f9bfce563d379ab0 to your computer and use it in GitHub Desktop.
Pass function as arguments
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'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: MyHomePage(testest: () { | |
print('test'); | |
}), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
final VoidCallback testest; | |
MyHomePage({@required this.testest}); | |
@override | |
_MyHomePage createState() => _MyHomePage(); | |
} | |
class _MyHomePage extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
drawer: | |
Drawer(child: ListTile(title: Text("test"), onTap: widget.testest)), | |
body: Column(children: [Text("Hello World")]), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment