Skip to content

Instantly share code, notes, and snippets.

View Andrious's full-sized avatar
🏠
Working from home

Andrious Solutions Andrious

🏠
Working from home
View GitHub Profile
@Andrious
Andrious / listenable_widget_builder.dart
Created November 19, 2024 01:40
A StatefulWidget that takes in a Listenable
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
// Widget builder allows for null
typedef MaybeBuildWidgetType = Widget? Function(BuildContext context);
/// Creates a widget that rebuilds when the given listenable calls
/// notifyListeners() function
class ListenableWidgetBuilder extends StatefulWidget {
/// The arguments is not required.
@Andrious
Andrious / impl_change_notifier_mixin.dart
Created November 19, 2024 01:37
A ChangeNotifier for a specific State class.
import 'package:flutter/material.dart';
import '/listenable_widget_builder.dart';
import '/main_listenable.dart';
/// Allows you to use a ChangeNotifier as a Mixin
///
/// setBuilder(WidgetBuilder? builder) rebuilds with every setState() call.
///
@Andrious
Andrious / counter_listenable.dart
Created November 19, 2024 01:33
Counter App using a ChangeNotifier Mixin
//
import 'package:flutter/material.dart';
import 'impl_change_notifier_mixin.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@Andrious
Andrious / three_counter_app_with_prints
Last active March 8, 2024 02:59
Two Screens with Three Counters and Print() functions highlight the StatefulWidgets' lifecycle
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
/// Highlights UI while debugging.
import 'package:flutter/rendering.dart' as debug;
void main() => runApp(MyApp());
///
class MyApp extends StatelessWidget {
@Andrious
Andrious / counter_app_with_prints.dart
Created March 1, 2024 02:11
The Counter App with a prints() functions highlighting the system & user events
//
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@Andrious
Andrious / inheritedwidget_state_mixin.dart
Last active March 15, 2024 01:22
Providing a built-in InheritedWidget to a State class
//
// Any State object 'with' this mixin has then a built-in InheritedWidget
//
//
import 'package:flutter/material.dart';
/// Supplies an InheritedWidget to a State class
///
mixin InheritedWidgetStateMixin<T extends StatefulWidget> on State<T> {
@Andrious
Andrious / statex_counter_app.dart
Created September 28, 2023 15:35
Counter Example App using StateX v. 4.7
import 'package:flutter/material.dart';
import 'package:state_extended/state_extended.dart';
/// Pass the boolean true take make this humble example app more efficient.
void main() => runApp(const StateXCounterPage(useInherited: false));
class StateXCounterPage extends StatefulWidget {
const StateXCounterPage({
super.key,
@Andrious
Andrious / statex_readme_example_app.dart
Last active August 20, 2023 03:01
Counter App Example using the Pub.dev package, state_extended
//
import 'package:flutter/material.dart';
import 'package:state_extended/state_extended.dart';
void main() => runApp(const MyApp(key: Key('MyApp')));
/// README.md example app
class MyApp extends StatefulWidget {
///
@Andrious
Andrious / statex_counter_app.dart
Created June 30, 2023 20:47
Counter example app demonstrating the StateX class
import 'package:fluttery_framework/view.dart';
import 'package:fluttery_framework/controller.dart';
void main() => runApp(MyApp());
class MyApp extends AppStatefulWidget {
MyApp({Key? key}) : super(key: key);
@override
@Andrious
Andrious / futurebuilder_mixin.dart
Last active March 24, 2022 21:06
A mixin to supply a 'built-in' FutureBuilder Widget to a State object or any object.
///
/// Supply a FutureBuilder to a State object.
///
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Replace 'dart:io' for Web applications
import 'package:universal_platform/universal_platform.dart';