simple_sheet_music 0.0.1-dev.1 copy "simple_sheet_music: ^0.0.1-dev.1" to clipboard
simple_sheet_music: ^0.0.1-dev.1 copied to clipboard

A Flutter package for rendering sheet music on canvas.

example/lib/main.dart

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const SimpleSheetMusicDemo());
  }
}

class SimpleSheetMusicDemo extends StatefulWidget {
  const SimpleSheetMusicDemo({super.key});

  @override
  State<StatefulWidget> createState() {
    return SimpleSheetMusicDemoState();
  }
}

class SimpleSheetMusicDemoState extends State {
  late final List<MusicObjectStyle> musicObjects;
  late final Measure measure;
  late final Staff staff;
  late final ClefType initialClefType;

  @override
  void initState() {
    initialClefType = ClefType.treble;
    musicObjects = [
      const Clef(ClefType.treble),
      const Note(
          pitch: Pitch.c4,
          noteDuration: NoteDuration.eighth,
          accidental: Accidental.sharp,
          fingering: Fingering.one),
      const Note(
          pitch: Pitch.e4,
          noteDuration: NoteDuration.eighth,
          fingering: Fingering.two),
      const Note(
          pitch: Pitch.g4,
          noteDuration: NoteDuration.eighth,
          fingering: Fingering.three),
      const Note(
          pitch: Pitch.c5,
          noteDuration: NoteDuration.eighth,
          accidental: Accidental.flat,
          fingering: Fingering.four),
    ];
    measure = Measure(musicObjects);
    staff = Staff([measure]);

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    final height = screenSize.height / 2;
    final width = screenSize.width;
    return Scaffold(
        appBar: AppBar(title: const Text('Simple Sheet Music Example')),
        body: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
          SimpleSheetMusic(
            initialClefType: initialClefType,
            margin: const EdgeInsets.all(10),
            height: height,
            width: width,
            staffs: [staff],
          )
        ]));
  }
}
11
likes
0
pub points
61%
popularity

Publisher

unverified uploader

A Flutter package for rendering sheet music on canvas.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

async, flutter, golden_toolkit

More

Packages that depend on simple_sheet_music