flutter_virtual_piano 0.0.9 copy "flutter_virtual_piano: ^0.0.9" to clipboard
flutter_virtual_piano: ^0.0.9 copied to clipboard

A package for rendering an interactive virtual piano with Flutter.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_virtual_piano/flutter_virtual_piano.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Virtual Piano"),
      ),
      body: Padding(
        padding: const EdgeInsets.all(18.0),
        child: SizedBox(
          height: 80,
          child: VirtualPiano(
            noteRange: const RangeValues(61, 78),
            // noteRange: const RangeValues(60, 90),
            highlightedNoteSets: const [
              // HighlightedNoteSet({44, 55, 77, 32}, Colors.green),
              // HighlightedNoteSet({34, 45, 67, 32}, Colors.blue)
            ],
            onNotePressed: (note, pos) {
              print("note pressed $note pressed at $pos");
            },
            onNoteReleased: (note) {
              print("note released $note");
            },
            onNotePressSlide: (note, pos) {
              print("note slide $note pressed at $pos");
            },
            elevation: 0,
            showKeyLabels: true,
          ),
        ),
      ),
    );
  }
}
14
likes
140
points
53
downloads

Publisher

verified publisherinvisiblewrench.com

Weekly Downloads

A package for rendering an interactive virtual piano with Flutter.

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on flutter_virtual_piano