simulate 0.0.16 simulate: ^0.0.16 copied to clipboard
Simulate application or add device mock on your app or your flutter project suppoer cross platform android ios , linux , macos, windows.
simulate #
Simulate your project flutter on cross platform with frame device ( android , ios, desktop ) on your os without heavy vm
Demo #
flutter pub add simulate
// ignore_for_file: unused_local_variable, duplicate_ignore
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:simulate/simulate.dart';
void main() {
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
initSimulate();
}
runApp(
const App(),
);
}
class App extends StatelessWidget {
const App({
super.key,
});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Simulate(
isShowFrame: true, // set false for disabled
home: MaterialApp(
debugShowCheckedModeBanner: false,
debugShowMaterialGrid: false,
showPerformanceOverlay: false,
home: Home(),
),
),
);
}
}
For Windows apps #
Inside your application folder, go to windows\runner\main.cpp
and add these two lines at the beginning of the file:
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
For macOS apps #
Inside your application folder, go to macos\runner\MainFlutterWindow.swift
and add this line after the one saying import FlutterMacOS
:
import FlutterMacOS
import bitsdojo_window_macos // Add this line
Then change this line from:
class MainFlutterWindow: NSWindow {
to this:
class MainFlutterWindow: BitsdojoWindow {
After changing NSWindow
to BitsdojoWindow
add these lines below the line you changed:
override func bitsdojo_window_configure() -> UInt {
return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
}
Your code should now look like this:
class MainFlutterWindow: BitsdojoWindow {
override func bitsdojo_window_configure() -> UInt {
return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
}
override func awakeFromNib() {
... //rest of your code
#
If you don't want to use a custom frame and prefer the standard window titlebar and buttons, you can remove the BDW_CUSTOM_FRAME
flag from the code above.
If you don't want to hide the window on startup, you can remove the BDW_HIDE_ON_STARTUP
flag from the code above.
For Linux apps #
Inside your application folder, go to linux\my_application.cc
and add this line at the beginning of the file:
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
Then look for these two lines:
gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));
and change them to this:
auto bdw = bitsdojo_window_from(window); // <--- add this line
bdw->setCustomFrame(true); // <-- add this line
//gtk_window_set_default_size(window, 1280, 720); // <-- comment this line
gtk_widget_show(GTK_WIDGET(window));
As you can see, we commented the line calling gtk_window_set_default_size
and added these two lines before gtk_widget_show(GTK_WIDGET(window));
auto bdw = bitsdojo_window_from(window);
bdw->setCustomFrame(true);