ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 요즘 주변에 플루터 빌런(?) 이 있습니다.
    잡담 2018. 12. 7. 15:50

    구글에서 C#을 어떻게 개량해서 다트를 만들어서 플루터라는 걸 만들었다는데..


    이게 곧 뜰거라고 익혀야한다는 빌런(?)이 계십니다.


    혹해서 한번 샘프루 코드를 확인.



    class CounterState extends State<Counter> {
      int counter = 0;
    
      void increment() {
        // Tells the Flutter framework that state has changed,
        // so the framework can run build() and update the display.
        setState(() {
          counter++;
        });
      }
    
      Widget build(BuildContext context) {
        // This method is rerun every time setState is called.
        // The Flutter framework has been optimized to make rerunning
        // build methods fast, so that you can just rebuild anything that
        // needs updating rather than having to individually change
        // instances of widgets.
        return Row(
          children: <Widget>[
            RaisedButton(
              onPressed: increment,
              child: Text('Increment'),
            ),
            Text('Count: $counter'),
          ],
        );
      }
    }


    리액트-리덕스식 구조를 java에 녹여놓은듯한 구조.


    널 세이프티는 지원하지 않는다는데 그건 매우 마음에 걸립니다.


    널 세이프티 못 잃어..


    class SampleApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Sample App',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: SampleAppPage(),
        );
      }
    }
    
    class SampleAppPage extends StatefulWidget {
      SampleAppPage({Key key}) : super(key: key);
    
      @override
      _SampleAppPageState createState() => _SampleAppPageState();
    }
    
    class _SampleAppPageState extends State<SampleAppPage> {
      // Default placeholder text
      String textToShow = "I Like Flutter";
      void _updateText() {
        setState(() {
          // update the text
          textToShow = "Flutter is Awesome!";
        });
      }
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text("Sample App"),
          ),
          body: Center(child: Text(textToShow)),
          floatingActionButton: FloatingActionButton(
            onPressed: _updateText,
            tooltip: 'Update Text',
            child: Icon(Icons.update),
          ),
        );
      }
    }


    댓글 2

Designed by Tistory.