Skip to content

Instantly share code, notes, and snippets.

View justinmc's full-sized avatar

Justin McCandless justinmc

View GitHub Profile
@justinmc
justinmc / main.dart
Created February 20, 2024 21:45
The different ways to select text in Flutter.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@justinmc
justinmc / main.dart
Created August 21, 2023 18:29
An example of async form validation.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Async Validator Example',
debugShowCheckedModeBanner: false,
@justinmc
justinmc / main.dart
Created June 30, 2023 17:44
Demonstrates undesired full width of link
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
Executing tasks: [:app:assembleDebug] in project /usr/local/google/home/jmccandless/AndroidStudioProjects/PredictiveBackMostBasic
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:dataBindingMergeDependencyArtifactsDebug FAILED
> Task :app:dataBindingMergeGenClassesDebug FAILED
> Task :app:generateDebugResValues UP-TO-DATE
@justinmc
justinmc / main.dart
Created May 15, 2023 18:43
Can't do nested Navigators and nested CanPopScopes
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This sample demonstrates nested navigation in a bottom navigation bar.
import 'package:flutter/material.dart';
// There are three possible tabs.
enum _Tab {
@justinmc
justinmc / main.dart
Created April 11, 2023 20:54
Predictive back with go_router working without modifications to go_router
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/scheduler.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@justinmc
justinmc / main.dart
Created April 10, 2023 23:47
A simple GoRouter example to use to test predictive back. It doesn't work out of the box. Always exits the app.
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
void main() => runApp(_MyApp());
@justinmc
justinmc / main.dart
Created April 10, 2023 23:32
Nested GoRouters with predictive back
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(_MyApp());
@justinmc
justinmc / main.dart
Created April 10, 2023 22:30
A vanilla example of nested GoRouters, without the use of WillPopScope.
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is a vanilla example of nested GoRouters.
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
@justinmc
justinmc / main.dart
Created April 7, 2023 22:23
This gist illustrates that a WillPopScope widget inside of a nested Navigator widget has no effect.
import 'package:flutter/material.dart';
void main() => runApp(_MyApp());
class _MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/nested_navigator',
routes: <String, WidgetBuilder>{