Skip to content

Instantly share code, notes, and snippets.

View hongsw's full-sized avatar
🎯
Focusing

Seungwoo hong hongsw

🎯
Focusing
View GitHub Profile
@hongsw
hongsw / main.dart
Created October 17, 2023 10:55
gpt4v test
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
@hongsw
hongsw / main.dart
Last active October 10, 2023 13:21
사용자의 이름을 입력받아 화면에 출력하는 앱
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@hongsw
hongsw / main.dart
Last active October 10, 2023 12:43
새로운 페이지를 만들기, Widget Class
import 'package:flutter/material.dart';
// 참고 : https://docs.flutter.dev/cookbook/navigation/navigation-basics
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@hongsw
hongsw / main.dart
Last active October 10, 2023 12:35
반복된 요소를 새로운 위젯으로 만들기
import 'package:flutter/material.dart';
// 참조 : https://api.flutter.dev/flutter/material/ListTile-class.html#material.ListTile.3
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@hongsw
hongsw / main.dart
Created September 12, 2023 16:16
FizzBuzz in Dart without IF
void main() {
for (int i = 1; i <= 100; i++) {
String output = "";
var fizz = ["", "Fizz"];
var buzz = ["", "Buzz"];
output += fizz[i % 3 == 0 ? 1 : 0];
output += buzz[i % 5 == 0 ? 1 : 0];
@hongsw
hongsw / main.dart
Last active September 12, 2023 15:57
Dart 'PPAP' Song 
void main() {
// 단계 1: 🍎 + 🖊 = 🍎🖊
String pen = '🖊';
print('Pen: $pen'); // 🖊
String apple = '🍎';
print('Apple: $apple'); // 🍎
String ap = apple + pen;
print('AP: $ap'); // 🍎🖊
// 단계 2: 🍍 + 🖊 = 🍍🖊
@hongsw
hongsw / main.dart
Last active September 12, 2023 15:54
dart string functions
void main() {
var hello = 'Hello, 🌍!';
print(hello.toUpperCase()); // Output: "HELLO, 🌍!"
hello = 'Hello, 🌍!';
print(hello.toLowerCase()); // Output: "hello, 🌍!"
hello = ' Hello, 🌍! ';
print(hello.trim()); // Output: "Hello, 🌍!"
@hongsw
hongsw / get_flutter_sample_game_template.sh
Created September 4, 2023 21:24
to get game_template only in sample repo, https://flutter.dev/games
git clone --filter=blob:none --no-checkout --depth 1 --sparse https://github.com/flutter/samples.git
cd samples
ls
git sparse-checkout add game_template
git checkout
ls
@hongsw
hongsw / main.dart
Last active May 24, 2023 04:34
guardianapis 이용 예시 
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> fetchPosts() async {
final response =
await http.get(Uri.parse('https://content.guardianapis.com/search?show-fields=thumbnail&q=food%20korean&api-key=test'));
if (response.statusCode == 200) {
// API 서버에서 데이터를 정상적으로 가져왔을 때