0

it might be stupid question but I am completely new in flutter, I am playing with desktop app for macOS using Flutter. I don’t want to follow any design rules and I’m just playing with basic layout.

My question: Is it necessary to start each App with one of the predefined root widget?

MaterialApp()
WidgetApp()
CupertinoApp()

Can our App just start with Container() as my code below?

void main() {
  runApp(
    new Directionality(textDirection: TextDirection.ltr, child: MyApp())
    );
}
// Root of App
class MyApp extends StatelessWidget {
 
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {  
    
    var mainGrey = parseColor('#282828');
    var dddColor = parseColor('#3e3e3e');
    
    var rootWidget = Container(
      decoration: BoxDecoration(gradient: 
      LinearGradient(begin: Alignment.topLeft,
                     end: Alignment.bottomRight,
                     colors: [mainGrey, dddColor], stops: [0.5, 1.0] )
                  ),
      //color: parseColor('#282828'),
      //color:Color.fromRGBO(50, 50, 50, 0.5),
        child: Column(        
          children: [
            Expanded(child:
            Container(child:
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                Flexible(
                  flex:1,
                  child: Container(
                      padding: const EdgeInsets.all(7),
                      decoration: BoxDecoration( border: Border.all(width: 1.0, color: Colors.blue[100])),
                      width: 200,
                      child: _myListMenu(context)
                      ),
                  
                ),
                Expanded(
                  flex:3,
                  child: Center(child: MainView() )
                ),],),
            )),
            Container(//Bottom bar
              height:30,
              color:Colors.blue,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children:[Text('App Footer', textAlign: TextAlign.end,), ])
              ,)
            ]
        ),
      );
    return rootWidget;
  }
}

Is it completely bad design? Or can we use flutter like this? Of course I met a few problems. Text directionality was missing and I can't access MediaQuery.

TomRavn
  • 1,134
  • 14
  • 30
  • It depends on what you mean by bad design. You can use the Flutter SDK to whatever purpose you see fit. If you don't want to use any of the code/design patterns and want to use your own structures, you are free to do so. As long as you are ok with dealing with the issues that you already mentioned, the ones you still haven't found, and knowing that it's likely that you will not find a lot of help with Flutter problems if you don't follow the more standard patterns. – J. S. Aug 13 '20 at 13:21
  • Yeah what I mean by bad design - good question. I am not sure. I have read that WidgetApp is for those of us who don't want to follow any design rules. I wanted to start without any those fancy things which are inside MaterialApp etc. But know I see that there are routers, MediaQuery, text Directionality. I wonder if I am able to recreate some of these things on my own, or I should rather stop hitting the wall in this case and follow standard rules. – TomRavn Aug 13 '20 at 13:38

1 Answers1

0

img ddier

from didierboelens blog

When we are writing an Flutter application, using Dart, we remain at the level of the Flutter Framework (in green).

The Flutter Framework interacts with the Flutter Engine (in blue), via an abstraction layer, called Window. This abstraction layer exposes a series of APIs to communicate, indirectly, with the device.

This is also via this abstraction layer that the Flutter Engine notifies the Flutter Framework when, among others:

  • an event of interest happens at the device level (orientation change, settings changes, memory issue, application running state…)
  • some event happens at the glass level (= gesture)
  • the platform channel sends some data
  • but also and mainly, when the Flutter Engine is ready to render a new frame
griffins
  • 7,079
  • 4
  • 29
  • 54