Skip to content

Instantly share code, notes, and snippets.

@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:51
Adaptive UI Talk: Example of handling light mode and dark mode in Cupertino.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart' show Icons;
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:25
Adaptive UI Talk: MenuBar example
// 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.
/// Flutter code sample for [MenuBar].
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:10
Adaptive UI Talk: Example of adding a custom button to a TextField's context menu on all platforms.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:09
Adaptive UI Talk: An example of adapting to window size using MediaQuery.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:09
Adaptive UI Talk: Example of handling light mode and dark mode in Material.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:08
Adaptive UI Talk FocusableActionDetector Example
// 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/material.dart';
void main() {
runApp(const MainApp());
}
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:02
Adaptive UI Talk LayoutBuilder Example
// 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.
/// Flutter code sample for [LayoutBuilder].
import 'package:flutter/material.dart';
void main() => runApp(const LayoutBuilderExample());
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:01
Adaptive UI Talk AnimatedBuilder Example
// 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/material.dart';
void main() => runApp(const AnimatedBuilderExample());
/// This widget listens for changes in the focus state of the subtree defined by
/// its [child] widget, changing the border and color of the container it is in
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:19 — forked from kwalrath/main.dart
Java-to-Dart codelab: CircleMock example
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:13 — forked from kwalrath/main.dart
Java-to-Dart codelab: Factory constructor
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}