Skip to content

Instantly share code, notes, and snippets.

View Toglefritz's full-sized avatar

Scott Hatfield Toglefritz

View GitHub Profile
@Toglefritz
Toglefritz / .cursorrules
Created June 14, 2025 00:05
Cursor Clean Modular Flutter Architecture Ruleset
// Vibe Coding Style Rules for Flutter Projects
// Purpose
// These rules guide the Cursor system in building and editing Flutter apps using a consistent, scalable, and maintainable structure, inspired by clean architecture and practical experience.
// Documentation Philosophy
// All code should be documented with the assumption that another developer will continue the work.
// Excellent documentation ensures knowledge transfer, supports scalability, and reduces onboarding time.
// Every feature should include inline comments, usage examples when helpful, and README-style explanations in the feature folder when appropriate.
@Toglefritz
Toglefritz / gist:92f59404cb363c5e5435d5b7a4017acb
Created January 26, 2025 15:20
Dart Doc Markdown Generator Flow Diagram
flowchart LR
A[Start: CLI Command] --> B[Traverse Directory Structure]
B -->|DirectoryTraversal.findDartFiles| C{Identify Dart Files}
C -->|Dart Files Found| D[Parse Dart Files]
C -->|No Dart Files Found| Z[End: No Action]
D -->|DartParser.parseFile| E{Extract Metadata}
E -->|Classes, Methods, Fields| F[Generate Markdown Documentation]
F -->|MarkdownGenerator.generateMarkdown| G{Write Files to Output Directory}
G --> H[Markdown Documentation Ready]
H --> I[Integration with Docusaurus, GitBook, MkDocs]
@Toglefritz
Toglefritz / clock_controller.dart
Last active July 2, 2023 19:09
ClockController class from Clocky McClockface app
/// A controller class designed for driving a clock interface in a Flutter application.
class ClockController with ChangeNotifier {
/// The current time in 12-hour format.
late DateTime _currentTime;
// Getter for the current time
DateTime get currentTime => _currentTime;
/// A [DateTime] when the alarm will expire and alert the user.
DateTime? _alarmTime;
@Toglefritz
Toglefritz / equivalent_setter_and_function_calls.dart
Created July 2, 2023 18:38
equivalent setter and function calls example
/// This block uses the setter defined in the previous example.
try {
alarm = alarmTime;
print('Alarm set for: $alarm');
} catch (e) {
print('Error: $e');
}
/// This block uses the equivalent function defined in the previous example.
try {
/// This is a setter used to set the value of the private variable, `_alarm`
set alarm(DateTime alarmTime) {
if(alarmTime.hour < 5) {
throw Exception('Nope. That is far to early to set an alarm.');
} else {
_alarm = alarmTime;
}
}
/// This is an equivalent function, also used to set the value of the private variable, `_alarm`
@Toglefritz
Toglefritz / clock_controller_simplified.dart
Created July 2, 2023 18:25
Private variables in Dart classes example
/// A controller class designed for driving a clock interface in a Flutter application.
class ClockController with ChangeNotifier {
/// The current time in 12-hour format.
late DateTime _currentTime;
// Getter for the current time
DateTime get currentTime => _currentTime;
/// A [DateTime] when the alarm should be triggered
DateTime? _alarm;
@Toglefritz
Toglefritz / clock_controller_simplified.dart
Created July 2, 2023 14:21
Private variables in Dart classes example
/// A controller class designed for driving a clock interface in a Flutter application.
class ClockController with ChangeNotifier {
/// The current time in 12-hour format.
late DateTime _currentTime;
// Getter for the current time
DateTime get currentTime => _currentTime;
ClockController() {
_currentTime = DateTime.now();
@Toglefritz
Toglefritz / variable_scoping_example.dart
Created June 30, 2023 11:46
Flutter/Dart private versus public variable
class SimpleClass {
// Public variable, accessible from outside the class
String publicVariable;
// Private variable, accessible only within this class
String _privateVariable;
SimpleClass(this.publicVariable, this._privateVariable);
}
@Toglefritz
Toglefritz / ic_launcher.xml
Created September 10, 2022 02:10
Android drawable resource for themed icon support
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
<monochrome android:drawable="@mipmap/ic_launcher_monochrome" />
</adaptive-icon>
@Toglefritz
Toglefritz / partly_windy_using_openai_completion.dart
Created July 30, 2022 02:32
A widget that uses the OpenAI completions API integration in the Partly Windy app to get a response from the OpenAI ML models.
return FutureBuilder(
future: CompletionsApi.getForecast(constraints.maxWidth < 300 ? 6 : 9),
builder: (BuildContext context, AsyncSnapshot<String?> forecast) {
if (forecast.hasData) {
dailyForecast = forecast.data;
return Text(dailyForecast);
} else {
// Display a loading indicator while waiting for the forecast
return const CircularProgressIndicator();
}