먼저 Radio<TYPE>으로 라디오 버튼을 만들어준다.

 

각 라디오가 서로 그룹임을 알려주려면 하나의 인스턴스를 서로 바라보고 있으면 된다.

int number = 0;

@override
Widget build(BuildContext context) {
  return Column(
    children: [
      Radio<int> (
        value: 0,
        groupValue: number,
      ),
      
      Radio<int> (
        value: 1,
        groupValue: number,
      )
    ],
  )
}

 

 

value는 각 라디오가 가지고 있는 고유 값을 뜻하며, 라디오 버튼을 클릭했을 때 onChanged함수를 통해서 값이 전달된다.

 

 

색상

activeColor를 넣어주어야 isChecked와 기본 색상이다.

 

 

 

https://api.flutter.dev/flutter/material/Radio-class.html

 

Radio class - material library - Dart API

A Material Design radio button. Used to select between a number of mutually exclusive values. When one radio button in a group is selected, the other radio buttons in the group cease to be selected. The values are of type T, the type parameter of the Radio

api.flutter.dev

 

 

Hello Flutter Worldwide.

Today I introduce one of the indie flutter packages.

It is name `flutter_logcat`

 

This package will be incredibly helpful to all of you.
If you make good use of logs, it will make development much more convenient.

 

In Flutter, logs are displayed in the console without any distinguishing colors.
However, by using this package, you can view messages in the console with colors that you define.
Additionally, you can configure it so that logs are hidden in debug mode, and you can also set it to display tags, file paths, and timestamps.

 

 

Usage is very simple!

 

Try it!

 

 

https://pub.dev/packages/flutter_logcat

 

flutter_logcat | Flutter package

You can view messages in the console with colors that you define. Also set it to display tags, file paths, and timestamps

pub.dev

 

랜덤하게 숫자를 받아야 한다. 그것을 '난수'라고 부른다.

1부터 10까지 랜덤하게 숫자를 받고 싶은 경우 Random을 사용한다.

 

Import

import 'dart:math';

 

Create Instance

var random = Random();

// 1 ~ 10
int result = random.nextInt(10) + 1;

 

+1을 해주지 않으면 0부터 9까지 숫자를 갖게 된다.

 

 

double형태로 받고 싶은 경우 (0.0 ~ 1.0)

double resultDouble = random.nextDouble();

 

 

Boolean형태로 받고 싶은 경우

bool resultBool = random.nextBool();

 

 

Color로 받고 싶은 경우

// Random from 'dart:math'
Color currentColor = Color((Random().nextDouble() * 0xFFFFFF).toInt());

+ Recent posts