flutter_프로젝트/0_초보_코드모음 4

flutter 코드모음 - 로컬에서 json 읽어오기

json 파일을 읽어 오는 코드서버에서는 아직이고...로컬에서 읽어 오기import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'dart:convert';void main() {  runApp(const MyApp());}class MyApp extends StatelessWidget {  const MyApp({super.key});  @override  Widget build(BuildContext context) {    return MaterialApp(home: const MyHomePage());  }}class MyHomePage extends StatefulWidget {  const MyHom..

flutter 코드 모음 - class 의 가장 간단한 예

클레스 처음 배우면 나오는 예제 class Car {  String name;  int price;  int maxSpeed;  Car({required this.name, required this.price, required this.maxSpeed});    void sale(){    price = (price * 0.9).toInt();  }}void main() {  Car bmw = Car(name: 'x5', price: 1000, maxSpeed: 250);  print (bmw.name);  print (bmw.price);  bmw.sale();  print ('세일 후 가격 ${bmw.price}');  bmw.sale();  print ('세일 후 가격 ${bmw.price}'); ..

flutter 코드 모음 - 그림을 표시 + 버튼을 누르면 회전

이미지를 표시하고, 아래 버튼을 누르면 회전하게 하는 코드import 'package:flutter/material.dart';import 'dart:math';void main() {  runApp(const MyApp());}class MyApp extends StatelessWidget {  const MyApp({super.key});  // This widget is the root of your application.  @override  Widget build(BuildContext context) {    return const MaterialApp(      home: MyHomePage(),    );  }}class MyHomePage extends StatefulWidget {  c..

dart : 클레스

class Car {   String name;   int price;   int maxSpeed; //   Car(String name, int price, int maxSpeed) { //     this.name = name; //     this.price = price; //     this.maxSpeed = maxSpeed; //   }// 위와 같이 쓰면 null 에러가 발생한다// 아래와 같이 수정한다  Car({required this.name, required this.price, required this.maxSpeed}); } void main() { //   Car bmw = new Car('x5', 1000, 250); // 초기화 할때는 아래와 같이 규칙에 따라서 진행한다. ..