Skip to content

Instantly share code, notes, and snippets.

View anoochit's full-sized avatar

Anuchit Chalothorn anoochit

View GitHub Profile
@anoochit
anoochit / chat.dart
Created August 13, 2022 05:34
chat message page
// show chat screen
import 'dart:developer';
import 'package:chat/consts.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
class ChatPage extends StatelessWidget {
ChatPage({Key? key, required this.roomId}) : super(key: key);
import 'dart:developer';
import 'package:chatapp/const.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class MapPage extends StatefulWidget {
MapPage({Key? key}) : super(key: key);
@anoochit
anoochit / station_model.dart
Created June 22, 2022 03:25
ev station model with geoflutterfire
// To parse this JSON data, do
//
// final station = stationFromJson(jsonString);
//import 'package:meta/meta.dart';
import 'dart:convert';
import 'dart:developer';
import 'package:evstation/const.dart';
import 'package:flutter/services.dart';
@anoochit
anoochit / stations.json
Created June 19, 2022 03:50
ev charging station
[
{
"id": "2",
"station_favorite": false,
"name": "สยามพารากอน",
"address": "ปทุมวัน, ปทุมวัน, กรุงเทพมหานคร",
"description": "GA [North] B18-B19,C18-C19",
"latitude": 13.745764,
"longitude": 100.53473,
"status": "ปิดบริการ",
@anoochit
anoochit / map_plugin.txt
Created June 16, 2022 01:19
note for map plugin
* https://pub.dev/packages/google_maps_flutter
* https://pub.dev/packages/geoflutterfire
* https://pub.dev/packages/geolocator
* https://pub.dev/packages/google_maps_utils
* https://pub.dev/packages/google_maps_cluster_manager
* https://pub.dev/packages/permission_handler
@anoochit
anoochit / bmi.dart
Created June 9, 2022 08:16
bmi calculator
double bmi = _weight / ((_height / 100) * (_height / 100));
setState(() {
if (bmi < 18.5) {
_result = "Underweight";
_color = Colors.lightBlue;
} else if (bmi < 25) {
_result = "Normal";
_color = Colors.green;
} else if (bmi < 30) {
_result = "Overweight";
import 'dart:developer' as dev;
import 'dart:math';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:location/location.dart';
import 'package:url_launcher/url_launcher.dart';
// (6) set value to drop down here
dev.log('goto page with docId = $value');
snapshot.data!.docs.where((e) => e.id == value).forEach((e) {
dev.log('${e.data()}');
setState(() {
dropdownValue = value.toString();
// set your value here
dev.log(e["timestamp"]);
});
});
// show dropdown
Center(
child: Container(
height: 50,
padding: const EdgeInsets.only(
left: 10.0,
right: 10.0,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.0),
@anoochit
anoochit / dropdown.dart
Created June 2, 2022 02:10
sample dropdown in future builder
// get log history
FutureBuilder(
future: FirebaseFirestore.instance.collection('sick').doc(widget.idcard).collection('logs').get(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
if (!snapshot.hasData) {
return Text('Loading...');