Skip to content

Instantly share code, notes, and snippets.

@jasonmcaffee
Created August 16, 2022 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonmcaffee/4b20c8c8ee68beb7919324142a477169 to your computer and use it in GitHub Desktop.
Save jasonmcaffee/4b20c8c8ee68beb7919324142a477169 to your computer and use it in GitHub Desktop.
decadent-flurry-9918

decadent-flurry-9918

Created with <3 with dartpad.dev.

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