Saturday, April 24, 2021

Simple UI with scaffold and appbar

 Simple UI:

---


//main.dart
import 'package:flutter/material.dart';

void main() {
   runApp(MyApp());

}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Hello Flutter App",
      home: new Material(
        color: Colors.deepPurple,
        child: Center(
          child: Text(
            "Hello Flutter!",
            textDirection: TextDirection.ltr,
            style: TextStyle(color: Colors.white,fontSize: 36.0),
          ),
        ),
      ),
    );
  }
}


With Scaffold and appbar added.:

--


import 'package:flutter/material.dart';

void main() {
   runApp(MyApp());

}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Hello Flutter App",
      home: Scaffold(
        appBar: AppBar(
          title: Text("Title in App Bar")
        ),
        body: Material(
          color: Colors.deepPurple,
          child: Center(
            child: Text(
              "Hello Flutter!",
              textDirection: TextDirection.ltr,
              style: TextStyle(color: Colors.white,fontSize: 36.0),
            ),
          ),
        )
      )

    );
  }
}

No comments:

Post a Comment