flutter(15)
-
${ } 와 $의 차이점은
코드에서 ${_lapTimes.length + 1}와 $_time의 차이는 Dart의 문자열 내에서 변수를 사용하는 방식입니다. 여기서 중괄호 {}의 사용 이유는 문자열 내에서 복잡한 표현식을 평가하기 위해서입니다.다음은 그 차이를 설명하는 예제입니다:${_lapTimes.length + 1}:중괄호 {} 안에 표현식을 넣어 문자열 내에서 평가됩니다._lapTimes.length + 1은 _lapTimes 리스트의 길이에 1을 더한 값입니다. 이 값을 문자열로 변환하여 삽입합니다.중괄호는 표현식을 명확하게 구분하는 데 사용됩니다. 만약 중괄호가 없다면, Dart는 문자열 내의 변수와 다른 텍스트를 구분하기 어려울 수 있습니다.$_time:단순히 _time 변수를 문자열 내에 삽입합니다.중괄호 {} 없이도..
2024.06.14 -
Live Templates 2024.06.14
-
backgroundColor
backgroundColor: Theme.of(context).colorScheme.inversePrimary, return Scaffold( appBar: AppBar( // TRY THIS: Try changing the color here to a specific color (to // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar // change color while the other colors stay the same. backgroundColor: Colors.blue, // Here we take the value from the MyHomePage object that was creat..
2024.06.14 -
플루터 제일 기본 화면에서
import 'package:flutter/material.dart';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 MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // TRY THIS: Try r..
2024.06.14 -
플루터 제일 기본 화면에서
import 'package:flutter/material.dart';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 MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // TRY THIS: Try r..
2024.06.14 -
Icon을 정의하고 변수로 불러오기
import 'package:flutter/material.dart';class ResultScreen extends StatelessWidget { final double height; final double weight; const ResultScreen({ Key? key, required this.weight, required this.height, }) : super(key: key); String _calcBmi(double bmi) { String result = '저체중'; if (bmi >= 35.0) { result = '고도 비만'; } else if (bmi >= 30.0) { result = '2단계 비만'; } el..
2024.06.14