Skip to content

Instantly share code, notes, and snippets.

View amani27's full-sized avatar

Amani amani27

  • Bathayan
  • Bangladesh
View GitHub Profile
@amani27
amani27 / callbacks.dart
Created February 4, 2023 13:12
Callback demo
import 'package:flutter/material.dart';
class MyCallbackPage extends StatefulWidget {
const MyCallbackPage({super.key});
@override
State<MyCallbackPage> createState() => _MyCallbackPageState();
}
class _MyCallbackPageState extends State<MyCallbackPage> {
@amani27
amani27 / prop_drilling.dart
Created February 4, 2023 13:06
Prop drilling demo
import 'package:flutter/material.dart';
class ParentWidget extends StatefulWidget {
const ParentWidget({super.key});
@override
State<ParentWidget> createState() => _ParentWidgetState();
}
class _ParentWidgetState extends State<ParentWidget> {
@amani27
amani27 / lifting_state_up.dart
Created February 4, 2023 13:05
Lifting State Up Demo
import 'package:flutter/material.dart';
class Counter extends StatefulWidget {
const Counter({super.key});
@override
State<Counter> createState() => _CounterState();
}
class _CounterState extends State<Counter> {
@amani27
amani27 / main.dart
Created January 7, 2023 06:30
Demonstrating Dart arithmetic operators
void main() {
int a = 16;
int b = 5;
var c = a / b; // Division operator
print('c = $c'); // Returns division result - double values
var i = a ~/ b; // Tilde slash operator
print('i = $i'); // Returns integer part of division result
@amani27
amani27 / switch_case_sample.dart
Created December 20, 2022 12:54
Demonstrating switch-case statements sample in Dart
void main() {
var command = 'OPEN';
switch (command) {
case 'CLOSED': // Empty case falls through.
// case 'CLOSED':
// print('CLOSED');
// break; // Omitting a break statement will show error
// case 'PENDING':
// print('PENDING');
@amani27
amani27 / control_flow_sample.dart
Created December 20, 2022 12:18
Demonstrating Dart control-flow statements
void main() {
int year = 1999;
List<String> planets = ['Jupiter', 'Saturn', 'Uranus', 'Neptune'];
if (year >= 2001) {
print('21st century');
} else if (year >= 1901) {
print('20th century');
}
@amani27
amani27 / dart_arithmetic_operators_example.dart
Last active December 20, 2022 08:54
Demonstrating Dart arithmetic operators
void main() {
int a = 16;
int b = 5;
var c = a / b; // Division operator
print('c = $c'); // Returns division result - double values
var i = a ~/ b; // Tilde slash operator
print('i = $i'); // Returns integer part of division result
@amani27
amani27 / null_safety_sample.dart
Created September 25, 2022 05:20
Demonstrating pre null safety issue
// ignore_for_file: use_key_in_widget_constructors
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
// ignore: must_be_immutable
@amani27
amani27 / comment_types.dart
Created September 24, 2022 09:55
Demonstrating types of comments in Dart
void main() {
// Single line comments
/*
Blocks of comments.
*/
/// Documentation
///
/// This is what you should use to document your classes.
@amani27
amani27 / dart_application_1.dart
Created September 24, 2022 09:16
Hello World Application in Dart
void main() {
print('Hello world!');
}