Created with <3 with dartpad.dev.
Created
August 16, 2022 18:34
-
-
Save jasonmcaffee/4b20c8c8ee68beb7919324142a477169 to your computer and use it in GitHub Desktop.
decadent-flurry-9918
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'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
typedef void AddButtonPressed(int connectionAgg, VoidCallback preventDefaultBehavior); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: darkBlue, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: DiscoveredAccounts(onAddPressed: (int conn, VoidCallback preventDefaultBehavior){ | |
print("add pressed"); | |
if(conn == 1){ | |
preventDefaultBehavior(); | |
} | |
}), | |
), | |
), | |
); | |
} | |
} | |
class DiscoveredAccounts extends StatelessWidget { | |
final AddButtonPressed? onAddPressed; | |
DiscoveredAccounts({this.onAddPressed}); | |
@override | |
Widget build(BuildContext context) { | |
return ElevatedButton( | |
onPressed: (){ | |
bool shouldPreventDefaultBehavior = false; | |
this.onAddPressed?.call(1, (){ | |
shouldPreventDefaultBehavior = true; | |
}); | |
print('shouldPreventDefaultBehavior: $shouldPreventDefaultBehavior'); | |
}, | |
child: const Text('Add') | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment