Skip to content

Instantly share code, notes, and snippets.

View Toglefritz's full-sized avatar

Scott Hatfield Toglefritz

View GitHub Profile
@Toglefritz
Toglefritz / daily_forecast_main.dart
Created July 22, 2022 11:08
The build method for main.dart in the Partly Windy app.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Partly Windy',
theme: buildLightTheme(),
darkTheme: buildDarkTheme(),
themeMode: ThemeMode.system,
debugShowCheckedModeBanner: false,
home: const DailyForecastRoute(),
);
@Toglefritz
Toglefritz / flutter_watch_and_phone_view_loading.dart
Created July 20, 2022 21:32
A Flutter Widget tree snippet that loads two different views depending upon the host device screen size.
// Return the view appropriate for the device screen size
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
debugPrint('Host device screen width: ${constraints.maxWidth}');
// Watch-sized device
if (constraints.maxWidth < 300) {
return DailyForecastViewWatch(this);
}
// Phone-sized device
@Toglefritz
Toglefritz / flutter_mvc.dart
Last active July 4, 2023 20:38
Basic template for Flutter "WidgetView" MVC design pattern
/// The Model Widget defines external parameters.
class Page extends StatefulWidget {
const Page({Key? key}) : super(key: key);
@override
PageController createState() => PageController();
}
/// The Controller handles the state and business logic.
class PageController extends State<Page> {