Thursday, March 28, 2019

Flutter: Calling from Separate file, AppBar and FloatingActionButton




main.dart
===================================

import 'package:flutter/material.dart';
import 'src/app.dart';

void main(){
 
  var app = new App();

  runApp(app);

}

===================================



app.dart
===================================

//  Import flutter Helper Library
import 'package:flutter/material.dart';

//Create a class that will be our custom widget
//This class must extend the 'StatelessWidget' base class

class App extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(

        home: Scaffold(

          appBar: AppBar(
            title: Text("Let's see Image"),
          ),

          floatingActionButton: FloatingActionButton(

            child: Icon(Icons.add),

            onPressed: (){
              print('Hi Floating Action Button');
            },
          ),
        )
    );
  }

}

//Must define the buid method that returns
//the widget that *this* widget will show


===================================

No comments:

Post a Comment