Skip to content

Instantly share code, notes, and snippets.

View kenresoft's full-sized avatar
💥
Building some innovative solutions.

Kenneth Amadi kenresoft

💥
Building some innovative solutions.
View GitHub Profile
@kenresoft
kenresoft / quiz_options.dart
Last active August 10, 2023 02:10
A function that returns the color of an option based on whether the option is correct and whether the option is selected.
void main(List<String> arguments) {
options = ['Multiply', 'Dart', 'Function', 'Gold', 'Silver', 'Bronze'];
String getColorForOption(String answer) {
bool correctAnswer = answer.startsWith("S");
bool isSelected = answer.startsWith("D");
if (isSelected) {
return correctAnswer ? 'Green' : 'Red';
} else {
return correctAnswer ? 'Green-Correction' : 'Grey';
@kenresoft
kenresoft / python-functions.ipynb
Created July 8, 2023 08:23
python-functions.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kenresoft
kenresoft / join.dart
Created June 3, 2023 18:31
Implementation of Dart join function
extension Str on List {
String joint([String separator = ""]) {
if (isEmpty) {
return "";
}
final StringBuffer buffer = StringBuffer();
for (var i = 0; i < length; i++) {
if (i > 0) {
buffer.write(separator);
}
@kenresoft
kenresoft / card_number_separator.dart
Last active June 1, 2023 07:42
Payment card number division with a space as the separator.
int divisions(String input) {
int divisions = 0;
for (var j = 3; j <= 4; ++j) {
//divisions = 2;
if (input.length % j == 0) {
return divisions = j;
}
}
return divisions;
@kenresoft
kenresoft / riff_switch.dart
Created May 30, 2023 22:05
Comparing Dart 2 and Dart 3 Switch statements.
final RiffSwitchType type;
RiffSwitchType get _type => type;
@override
Widget build(BuildContext context) {
// Dart 2
/*switch (_type) {
case RiffSwitchType.simple:
return _buildSimpleSwitch();
@kenresoft
kenresoft / main.dart
Last active June 1, 2023 07:38
Sample of my GoRouter setup methods in my main.dart
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]).then(appCallback);
}