piano
a flutter package that provides:
- logic for working with musical notes, clefs and octaves;
- a widget that can render notes on a clef;
- an interactive piano widget.
where is it used?
in “learn the notes”, a simple sight reading trainer you can find on the ios app store here and macos app store here.
how do i use it?
here’s an example app:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:piano/piano.dart';
void main() {
runapp(myapp());
}
class myapp extends statelesswidget {
@override
widget build(buildcontext context) {
return cupertinoapp(
title: 'piano demo',
home: center(
child: interactivepiano(
highlightednotes: [
noteposition(note: note.c, octave: 3)
],
naturalcolor: colors.white,
accidentalcolor: colors.black,
keywidth: 60,
noterange: noterange.forclefs([
clef.treble,
]),
onnotepositiontapped: (position) {
// use an audio library like flutter_midi to play the sound
},
),
));
}
}
Comments are closed.