This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://stackoverflow.com/questions/70272959/jsonencode-doesnt-work-with-enum-extensions-is-there-a-workaround | |
import 'dart:convert'; | |
enum Day { monday, tuesday } | |
extension ParseToJsonString on Day { | |
String toJson() { | |
return this.toString().split('.').last; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code is distributed under the MIT License. | |
// Copyright (c) 2018 Felix Angelov. | |
// Ported to dartpad.dev 2021 by Howard "horizons" Chong. | |
// You can find the original at https://github.com/felangel/bloc. | |
// Specifically, see https://github.com/felangel/bloc/tree/master/examples/flutter_counter | |
// | |
// The tutorial/guide at https://bloclibrary.dev/#/fluttercountertutorial describes this code. | |
// Linkback to DartPad: https://dartpad.dev/90da115645caf06ffe10dc8ab170f347 | |
// | |
// ===== TROUBLESHOOTING INSTRUCTIONS ===== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math' as math; | |
const double originX=5; | |
const double originY=5; | |
class Point { | |
double x; | |
double y; |
NewerOlder