Skip to content

Instantly share code, notes, and snippets.

@karanahuja-android
karanahuja-android / helloflutter.dart
Last active April 28, 2020 08:14
Flutter Hello World
import 'package:flutter/material.dart';
void main() {
runApp(
Text(
'Hello, world!',
textDirection: TextDirection.ltr,
),
);
}
@karanahuja-android
karanahuja-android / hellofluttercenter.dart
Last active April 28, 2020 07:48
Hello Flutter Center
import 'package:flutter/material.dart';
void main() {
runApp(
Center(
child: Text(
'Hello, world!',
textDirection: TextDirection.ltr,
),
),
);
import 'package:flutter/material.dart';
void main() {
runApp(new HelloWorldText());
}
class HelloWorldText extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
@karanahuja-android
karanahuja-android / hellostateless.dart
Created April 27, 2020 19:04
hellostateless.dart
import 'package:flutter/material.dart';
void main() {
runApp(new HelloWorld());
}
class HelloWorld extends StatelessWidget {
String mytext = "Hello World";
void goodbyeText(){
this.mytext = "GoodBye World";
print("inside goodbye text") ;
import 'package:flutter/material.dart';
void main() {
runApp(new HelloWorld());
}
class HelloWorld extends StatefulWidget {
@override
_HelloWorldState createState() => _HelloWorldState();
}
class _HelloWorldState extends State<HelloWorld> {
void main (){
print("start - please guess number");
int secretNumber = 5;
int userNumber = 3;
if (userNumber < secretNumber)
print("my number is high");
if (userNumber > secretNumber)
print("my number is low");
import 'package:flutter/material.dart';
void main() {
runApp(new HelloWorld());
}
class HelloWorld extends StatefulWidget {
@override
_HelloWorldState createState() => _HelloWorldState();
}
class _HelloWorldState extends State<HelloWorld> {
import 'dart:math';
import 'dart:io';
add (int first,int second,int playeranswer)
{
if (first + second == playeranswer)
{
print ("you got it!");
}
if (first + second != playeranswer)
@karanahuja-android
karanahuja-android / index.html
Created August 27, 2020 09:55
Get started with handlebars
<!DOCTYPE html>
<html>
<head>
<script src="handlebars.min-v4.7.6.js"></script>
<title></title>
</head>
<body>
<script type="text/javascript">
const template = Handlebars.compile("Name: {{name}}");
import 'dart:io';
import 'dart:math';
main ()
{
Random r = Random ();
var computer = r.nextInt (11);
var player = int.parse (stdin.readLineSync());
if (computer > player)
{