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 / app_counter_inherited.dart
Last active December 30, 2020 02:12
Simple startup app (counter app) demonstrating the InheritedWidget
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 September 27, 2021 08:36
A simple app demonstrating the MediaQuery widget
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 December 10, 2020 16:32
The proverbial 'counter app' stripped of its many comments.
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 December 3, 2020 03:18
Write Your First App with a BLoC
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 November 30, 2020 05:10
A Business Logic Component with access to the State object.
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 November 25, 2020 16:51
The Counter app with const constructors
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(
@Andrious
Andrious / theme_controller.dart
Created November 3, 2020 03:28
Class to supply 'dark mode' ThemeData and record the dark mode setting using the Preference plugin.
import 'package:flutter/material.dart' show ThemeData;
import 'package:prefs/prefs.dart';
/// The App's theme controller
class ThemeController {
factory ThemeController() => _this ??= ThemeController._();
ThemeController._() {
_isDarkmode = Prefs.getBool('darkmode', false);
}
@Andrious
Andrious / form_validation.dart
Last active September 21, 2020 23:10
Build a form with validation
// TextFormField & Form Validation.
// https://flutter.dev/docs/cookbook/forms/validation
class FormValidation extends StatelessWidget {
@override
Widget build(BuildContext context) {
final appTitle = 'Form Validation Demo';
return MaterialApp(
title: appTitle,
home: Scaffold(
@Andrious
Andrious / schedule_notifications.dart
Last active April 11, 2024 05:56
Utility class using the plugin, flutter_local_notifications.dart.
import 'dart:async' show Future;
import 'dart:math' show Random;
import 'dart:typed_data' show Int64List;
import 'dart:ui' show Color;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
//
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
@Andrious
Andrious / flutter_notifications_example.dart
Last active April 11, 2024 05:56
Example code for the library file, schedule_notifications.dart
import 'dart:async' show Future;
import 'dart:io' show File;
import 'dart:typed_data' show Int64List;
import 'dart:ui' show Color, FontWeight, Radius, VoidCallback;
import 'package:http/http.dart' as http;