728x90
반응형
어떤 날은 글로 쓰기보다 말로 남기고 싶을 때가 있다.
Flutter 메모 앱에 음성 녹음 기능을 더하면, 손으로 쓰기 어려운 순간에도 간편하게 기억을 기록할 수 있다.
이번 글에서는 Flutter에서 녹음 및 재생 기능을 구현하는 방법을 정리해본다.
🎙️ 필요한 패키지 설치
// pubspec.yaml
dependencies:
flutter_sound: ^9.2.13
permission_handler: ^11.3.1
path_provider: ^2.1.2
flutter_sound
는 녹음/재생 통합 지원,permission_handler
는 마이크 권한 요청,path_provider
는 저장 경로 탐색용이다.
🎛️ 권한 요청 및 기본 셋업
await Permission.microphone.request();
final dir = await getApplicationDocumentsDirectory();
final filePath = '${dir.path}/memo_record.aac';
마이크 사용 권한을 반드시 요청해야 하며,
저장할 파일 경로를 미리 지정해둔다.
🔴 녹음 시작 / 종료
FlutterSoundRecorder _recorder = FlutterSoundRecorder();
Future startRecording() async {
await _recorder.openRecorder();
await _recorder.startRecorder(toFile: filePath);
}
Future stopRecording() async {
await _recorder.stopRecorder();
await _recorder.closeRecorder();
}
startRecorder()
와 stopRecorder()
로 녹음을 컨트롤할 수 있다.
▶️ 음성 재생하기
FlutterSoundPlayer _player = FlutterSoundPlayer();
Future playRecording() async {
await _player.openPlayer();
await _player.startPlayer(fromURI: filePath);
}
파일 경로를 직접 전달해주면 녹음된 오디오를 재생할 수 있다.
📱 UI 구성 예시
Column(
children: [
IconButton(
icon: Icon(isRecording ? Icons.stop : Icons.mic),
onPressed: () async {
if (isRecording) {
await stopRecording();
} else {
await startRecording();
}
setState(() => isRecording = !isRecording);
},
),
ElevatedButton(
onPressed: playRecording,
child: Text("녹음 재생"),
)
],
)
마이크 아이콘으로 녹음 시작/종료를 컨트롤하고, 버튼으로 재생 기능을 제공한다.
🧩 메모와 연결하기
텍스트 메모 외에도 음성 파일 경로를 함께 저장하면
음성과 텍스트를 동시에 다루는 확장된 메모 시스템이 된다.
class Memo {
final int? id;
final String content;
final String? audioPath;
}
💡 UX 팁
- 녹음 시간 제한 설정: 예) 3분 이하
- 재생 시 진행 바(SeekBar) 추가
- 녹음 목록 관리 화면 별도 구성 고려
🧘 마무리하며
말 한마디가 긴 글보다 많은 것을 담기도 한다.
Flutter 메모 앱에 음성 메모 기능을 추가하는 것, 그건 단순한 기능이 아니라 또 다른 감정의 기록 방식이다.
쓰지 않아도, 기록할 수 있다.
✍️ 이 글은 터미널 밖으로 나온 개발자의 Flutter 메모 앱 만들기 여정입니다.
728x90
반응형
'Flutter > Flutter 메모 앱 만들기' 카테고리의 다른 글
검색 기능 구현 — 키워드로 빠르게 메모 찾기 (0) | 2025.05.28 |
---|---|
이미지 첨부 기능 — 사진과 함께 기억하기 (0) | 2025.05.28 |
다크 모드와 배경 커스터마이징 — 메모에 감성 더하기 (0) | 2025.05.28 |
메모 태그 분류 — 주제별로 필터링하는 법 (4) | 2025.05.28 |
메모 고정 핀 기능 — 자주 쓰는 메모는 상단 고정 (0) | 2025.05.28 |