Skip to content

Instantly share code, notes, and snippets.

import 'package:flutter/material.dart';
class ExampleScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hey there, boo!'),
),
body: Padding(
@chonghorizons
chonghorizons / main.dart
Created December 26, 2019 07:42
Flutter Demo, push counter (with some adjustments)
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyFancyApp());
}
class MyFancyApp extends StatelessWidget {
// final Firebase _firebase;
var probability=0.01 // 1%
var initialsize=500 //
var waves=[50,5,2,1]
// var probability=0.10 // 10%
// var initialsize=50 //
// var waves=[2,1]
// See this medium article on batch testing for the coronavirus:
// https://medium.com/@coronavirusnotalone/the-secret-way-to-reopen-schools-with-batch-testing-for-coronavirus-616433cd5ba4
@chonghorizons
chonghorizons / playwithclass_Dartpad.dart
Last active November 6, 2021 19:08
DART: Playing with class, initialization list.
import 'dart:math' as math;
const double originX=5;
const double originY=5;
class Point {
double x;
double y;
@chonghorizons
chonghorizons / final_const_dartpad_Nov2021.dart
Created November 6, 2021 19:39
Const and Final, Dartpad, samples of what can and cannot be edited, for a String and a Map
// Note: Although a final object cannot be modified, its fields can be changed. In comparison, a const object and its fields cannot be changed: they’re immutable.
void main() {
const String name='Howard';
final stats= {'age': 42, 'income': 0};
const unchangeableStats={'hair': "black", "race": "chinese"};
var normalMap= {};
print("My age is ${stats['age']}");
stats['age']=stats['age']!.toInt()+1;
@chonghorizons
chonghorizons / star_clipping_Dartpad.dart
Created November 6, 2021 21:42
Flutter, Star Path for clipping, N-pointed star clipper for Flutter
//Based on the blog article by "The Plumber" https://www.kindacode.com/article/flutter-drawing-an-n-pointed-star-with-customclipper/
// main.dart
import 'package:flutter/material.dart';
import 'dart:math' as math;
// This custom clipper help us achieve n-pointed star shape
class StarClipper extends CustomClipper<Path> {
/// The number of points of the star
@chonghorizons
chonghorizons / FractionalBoxPlay.dart
Last active November 18, 2021 20:42
Fractional Box in a Column, not working the way one would expect
// Copyright (c) 2021 Howard Chong
// See discussion of FractionalSizedBox in https://stackoverflow.com/questions/57242651/using-fractionallysizedbox-in-a-row/70026340#70026340
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
// Copyright 2017, 2020 The Flutter team. 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 FriendlyChatApp(),
);
@chonghorizons
chonghorizons / FlexibleWithEmptyContainers.dart
Last active November 27, 2021 01:10
Empty Containers don't render for Flexible, Flutter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Empty Containers aren't rendered",
debugShowCheckedModeBanner: false,
@chonghorizons
chonghorizons / flexiblesWorkWithEmptyContainers.dart
Created November 28, 2021 04:45
Flexibles Work with Empty Containers
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Empty Containers aren't rendered",
debugShowCheckedModeBanner: false,