Hey there,
I am having a bit of an issue figuring out exactly where these components are supposed to go within the overall application hierarchy. I tried to look for other projects on github which might be using the mixture of NativeShell and this library, but to my surprise, the only thing that came up was this repo's readme and the actual implementation within the library. Unfortunately, that didn't give me much to try and compare with. If at all possible, could I be pointed in the right direction on what needs to go where? Below is the bare minimum NativeShell setup necessary to produce a working window, which I was using from the Test folder of NativeShell. I wanted to start as minimal as possible to make sure things would work as expected before trying to build out anything, but I can't seem to get a window to load once I try and implement this library. I am most certainly missing a silly detail on where the AdwHeaderBar.minimalNativeshell() needs to actually go, but I just can't quite put my finger on where.
P.S. I tried using fix46, as I was looking at other repos that used this lib without NativeShell, so I figured it was worth a go since it had a header / body field, but unfortunately that would not build with NativeShell, something about the url_launcher it doesn't seem to like. The main branch at least build and "runs", even if I can't see it, so I figure best to probably stick with that.
Minimum from project test folder
import 'package:flutter/material.dart';
import 'package:nativeshell/nativeshell.dart';
void main() async {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTextStyle(
style: TextStyle(
color: Colors.white,
fontSize: 14,
),
child: Container(
color: Colors.black,
child: WindowWidget(
onCreateState: (initData) {
WindowState? state;
state ??= MainWindowState();
return state;
},
),
),
),
);
}
}
class MainWindowState extends WindowState {
@override
WindowSizingMode get windowSizingMode =>
WindowSizingMode.atLeastIntrinsicSize;
@override
Widget build(BuildContext context) {
return WindowLayoutProbe(
child: Container(
padding: EdgeInsets.all(20),
child: Center(child: Text('Welcome to NativeShell!')),
),
);
}
}
My attempt to implement the library into the test
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:nativeshell/nativeshell.dart';
import 'package:adwaita/adwaita.dart';
import 'package:get/get.dart';
import 'package:libadwaita/libadwaita.dart';
void main() async {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
theme: AdwaitaThemeData.dark(), // <--- added theme here
home: DefaultTextStyle(
style: TextStyle(
color: Colors.white,
fontSize: 14,
),
child: Container(
color: Colors.black,
child: WindowWidget(
onCreateState: (initData) {
WindowState? state;
state ??= MainWindowState();
return state;
},
),
),
),
);
}
}
class MainWindowState extends WindowState {
@override
WindowSizingMode get windowSizingMode =>
WindowSizingMode.atLeastIntrinsicSize;
// I tried several different overall setups, but could not get any to work.
// Such as putting the bar ^ up in the parent class wrapping the WindowWidget
// also a few variations of what you see here below, but so far everything
// I have tried results in no window actually loading.
@override
Widget build(BuildContext context) {
return AdwHeaderBar.minimalNativeshell( // <---- Header here?
window: Window.of(context) , // .parentWindow, currentWindowMenu
start: [
WindowLayoutProbe( // <--- Does this go in start?
child: Container(
padding: EdgeInsets.all(20),
child: Center(child: Text('Welcome to NativeShell!')),
),
),
],
);
}
}
Any help would be greatly appreciated!
Thanks,
-MH