Flutter UI Widgets

Nov 9 2021 · Dart 2.14, Flutter 2.5, VS Code 1.61

Part 1: Flutter UI Widgets

13. Explore Cupertino Widgets

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 12. Make Your App Design Responsive Next episode: 14. Build iOS Styled Forms

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

So far, we’ve built our app with material based widgets. Our app would look great on both Android and iOS because material widgets have been adapted for both platforms. We can view how our app would look and feel on different platforms. First lets take note of the default android behaviour. Currently, the appbar title is at the left side of the appbar.

platform: TargetPlatform.iOS,
class MainPage extends StatelessWidget {
  const MainPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      child: CupertinoTabScaffold(
        tabBar: CupertinoTabBar(
          backgroundColor: CupertinoColors.systemGrey5,
          items: <BottomNavigationBarItem>[
            const BottomNavigationBarItem(
              label: 'Home',
              icon: Icon(CupertinoIcons.home),
            ),
            const BottomNavigationBarItem(
              label: 'Inbox',
              icon: Icon(CupertinoIcons.mail),
            ),
          ],
        ),
        tabBuilder: (context, index) {
          switch (index) {
            case 0:
              return CupertinoTabView(builder: (context) {
                return const HomePage();
              });
            case 1:
              return CupertinoTabView(builder: (context) {
                return const InboxPage();
              });
            default:
              return Container();
          }
        },
      ),
    );
  }
}
// HomePage and InboxPage
...
@override
Widget build(BuildContext context) {
  return CupertinoPageScaffold(
    navigationBar: CupertinoNavigationBar(
      middle: Image.asset(
        'assets/images/logo_dark.png',
        width: 180,
      ),
      // For only HomePage
      trailing: IconButton(
        icon: Icon(CupertinoIcons.add_circled),
        onPressed: () {
        },
      ),
      // End
    ),
    child: ...
class ArticleCard extends StatelessWidget {
  final Article article;
  final bool isIOS; // New Code

  const ArticleCard({Key key, this.article, this.isIOS = true})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    if (isIOS) {
      return Container(
        margin: const EdgeInsets.all(16),
        padding: const EdgeInsets.only(bottom: 8),
        decoration: const BoxDecoration(
          border: Border(
            bottom: BorderSide(width: 1, color: CupertinoColors.systemGrey4),
          ),
        ),
        child: WideCard(article: article),
      );
    }
    return Card(
...
child: CupertinoActivityIndicator(
  radius: 24,
),
...