This is a beta build tutorial, so its structure, implementation steps, and sample code may continue to change.
Create Project
In this chapter, we will create a new Flutter project for our hotkey application.
Create Flutter Project
Run the following command to create a new Flutter project:
flutter create hotkey_app
cd hotkey_app
Add Dependencies
Add the following dependencies to pubspec.yaml:
dependencies:
flutter:
sdk: flutter
window_manager: ^0.3.0
hotkey_manager: ^0.1.7
provider: ^6.0.0
Configure macOS Permissions
- Open
macos/Runner/DebugProfile.entitlementsfile and add the following permissions:
<dict>
<key>com.apple.security.temporary-exception.apple-events</key>
<string>com.apple.systemevents</string>
</dict>
- Add the same configuration to
macos/Runner/Release.entitlements.
Clean Default Code
-
Open
lib/main.dartand remove the default counter example code. -
Create the basic application structure:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Hotkey App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hotkey App'),
),
body: Center(
child: Text('Hello World'),
),
);
}
}
Next Steps
Now that the project is set up, we will learn about window management in the next chapter.
Found an issue with this content?
Tell us what could be improved.
