개발/플루터(flutter)

bottom tabBar

----___<<<<< 2020. 4. 12. 18:26

import 'package:flutter/material.dart';
import 'package:flutterapptab/bottom_bar.dart';
import 'package:flutterapptab/home_screen.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "asdf",
      theme: ThemeData(
        brightness: Brightness.dark,
        primaryColor: Colors.black,
        accentColor: Colors.white,
      ),
      home: DefaultTabController(length: 4, child: Scaffold(
        body: TabBarView(
          physics: NeverScrollableScrollPhysics(),
          children: <Widget>[
            HomeScreen(),
            Container(child: Center(child: Text("2"),),),
            Container(child: Center(child: Text("3"),),),
            Container(child: Center(child: Text("4"),),),
          ],
        ),
        bottomNavigationBar: Bottom(),
      ),),
    );
  }
}
import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Center(
        child: Text("뿌우뿌우"),
      ),
    );
  }
}
import 'package:flutter/material.dart';

class Bottom extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.black,
      child: Container(height: 50, child: TabBar(
        labelColor: Colors.white,
        unselectedLabelColor: Colors.white60,
        indicatorColor: Colors.transparent,
        tabs: <Widget>[
          Tab(
              icon: Icon(Icons.home, size: 19,),
              child: Text("초급", style: TextStyle(fontSize: 10)),
          ),
          Tab(icon: Icon(Icons.home, size: 19,),
              child: Text("중급", style: TextStyle(fontSize: 10)),),
          Tab(icon: Icon(Icons.home, size: 19,),
              child: Text("상급", style: TextStyle(fontSize: 10)),),
          Tab(icon: Icon(Icons.home, size: 19,),
            child: Text("신", style: TextStyle(fontSize: 10)),),
        ],
      ),),
    );
  }
}

 

 

참조

[1] - https://www.inflearn.com/course/flutter-netflix-clone-app/lecture/37784

'개발 > 플루터(flutter)' 카테고리의 다른 글

flutter bottom tab  (0) 2020.04.23
flutter adb exited with exit code 1  (0) 2020.04.21
커플게임 앱 - 3  (0) 2020.04.09
커플게임 앱 - 2  (0) 2020.04.09
커플게임 앱 - 1  (0) 2020.04.09