Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Andrious Solutions Andrious

🏠
Working from home
View GitHub Profile
@Andrious
Andrious / futurebuilder_mixin.dart
Last active Mar 24, 2022
A mixin to supply a 'built-in' FutureBuilder Widget to a State object or any object.
View futurebuilder_mixin.dart
///
/// 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';
@Andrious
Andrious / inherited_state_mixin.dart
Last active Mar 24, 2022
Attach this Mixin to any State object will provide a built-in InheritedWidget
View inherited_state_mixin.dart
///
/// Any State object 'with' this mixin has then a built-in InheritedWidget
///
///
import 'package:flutter/material.dart';
///
mixin InheritedStateMixin<T extends StatefulWidget> on State<T> {
/// Traditionally called in the initState() function
void initInheritedState<U extends InheritedWidget>({
@Andrious
Andrious / navigate_with_named_routes.dart
Last active Jan 8, 2021
Example of the 'routes table' and the pushedNamed() function.
View navigate_with_named_routes.dart
import 'package:flutter/material.dart';
void main() => runApp(NavigateNamedRoutes());
class NavigateNamedRoutes extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Named Routes Demo',
initialRoute: '/',
routes: {
@Andrious
Andrious / navigate_two_routes.dart
Last active Jan 6, 2021
Demonstration of Flutter's Naviagtion system
View navigate_two_routes.dart
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
title: 'Navigation Basics',
home: FirstRoute(),
));
class FirstRoute extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
@Andrious
Andrious / app_counter_inherited.dart
Last active Dec 30, 2020
Simple startup app (counter app) demonstrating the InheritedWidget
View app_counter_inherited.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@Andrious
Andrious / mediaQuery.dart
Last active Sep 27, 2021
A simple app demonstrating the MediaQuery widget
View mediaQuery.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'MediaQuery Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
@Andrious
Andrious / counter_app_minimum.dart
Created Dec 10, 2020
The proverbial 'counter app' stripped of its many comments.
View counter_app_minimum.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
@Andrious
Andrious / write_your_first_app_bloc.dart
Last active Dec 3, 2020
Write Your First App with a BLoC
View write_your_first_app_bloc.dart
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'
show
CupertinoApp,
CupertinoButton,
CupertinoColors,
CupertinoPageRoute,
@Andrious
Andrious / bloc_state.dart
Created Nov 30, 2020
A Business Logic Component with access to the State object.
View bloc_state.dart
import 'package:flutter/material.dart';
class Bloc extends StateSetter {
//
Bloc([StateBloc state]) : super() {
// Associate it with the specified State object.
addState(state);
// Include it in a collection of Blocs.
@Andrious
Andrious / const_counter_app
Last active Nov 25, 2020
The Counter app with const constructors
View const_counter_app
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
theme: ThemeData(