Created
June 19, 2021 22:28
-
-
Save IsmailAlamKhan/a3ed827eccaaae22a1f72c6fba4f2b1d to your computer and use it in GitHub Desktop.
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( | |
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, | |
home: const Scaffold(body: Center(child: Home())), | |
); | |
} | |
} | |
class Home extends StatelessWidget { | |
const Home({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Button( | |
// onPreesed: print, | |
// onPreesed: (value) => print(value), | |
onPreesed: (value) { | |
print(value); | |
}, | |
); | |
} | |
} | |
class Button extends StatelessWidget { | |
const Button({ | |
Key? key, | |
required this.onPreesed, | |
}) : super(key: key); | |
final ValueChanged<String> onPreesed; | |
@override | |
Widget build(BuildContext context) { | |
return ElevatedButton( | |
onPressed: () => onPreesed('You are gonna die for pressing me'), | |
child: const Text("Don't press me"), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment