Skip to content

Instantly share code, notes, and snippets.

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

Christian Findlay MelbourneDeveloper

🏠
Working from home
View GitHub Profile
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Last active May 11, 2023 21:27
Day Of Week
void main() {
var dayOfWeek = 'Monday';
var dayNumber = switch (dayOfWeek) {
'Monday' => 1,
'Tuesday' => 2,
'Wednesday' => 3,
'Thursday' => 4,
'Friday' => 5,
'Saturday' => 6,
'Sunday' => 7,
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created May 11, 2023 09:53
Switch Expression Example
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: FutureBuilder(
future: Future<String>.delayed(
const Duration(seconds: 3), () => 'Hello World!'),
import 'package:flutter/material.dart';
final colors = [
const Color.fromARGB(255, 255, 0, 0),
const Color.fromARGB(255, 0, 255, 0),
const Color.fromARGB(255, 0, 0, 255),
];
void main() {
runApp(
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red)
.copyWith(surface: Colors.pink),
cardTheme: CardTheme(
shape: RoundedRectangleBorder(
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
theme: ThemeData(
fontFamily: 'Roboto',
useMaterial3: true,
textTheme: const TextTheme(
bodyMedium: TextStyle(
color: Colors.red,
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
useMaterial3: true,
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.blue,
).copyWith(
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Last active February 26, 2025 05:45
Flutter Theme Toggler
import 'package:flutter/material.dart';
ThemeData lightTheme = ThemeData(
brightness: Brightness.light,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
);
ThemeData darkTheme = ThemeData(
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSeed(
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Last active April 18, 2023 21:33
State Management Components Example
import 'package:flutter/material.dart';
import 'dart:async';
///🎮 Controller
///This class handles business logic and notifies listeners when the state changes.
///In this example, the controller holds the state, which is the counter.
///The state is mutable
class CounterController extends ChangeNotifier {
CounterController(this.apiService);
@MelbourneDeveloper
MelbourneDeveloper / test.dart
Created April 18, 2023 04:39
Type Safe Container
import 'dart:async';
import 'package:test/test.dart';
class User {
final String displayName;
final String email;
User(this.displayName, this.email);
}
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created April 17, 2023 05:10
Different Appraches To Conditional Display
// ✅ 1. Nested ternaries
Widget _mainDisplay1(
AsyncSnapshot<ValueNotifier<int>> snapshot, BuildContext context) =>
snapshot.hasData
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),