iT邦幫忙

2023 iThome 鐵人賽

DAY 9
0
自我挑戰組

基礎學習Flutter系列 第 9

Day9-學習[Building for iOS with Flutter]得出目標應用程式

  • 分享至 

  • xImage
  •  

影片中使用Hello World 進行改編

導入Cupertino包

import 'package: flutter/cupertino.dart';

https://ithelp.ithome.com.tw/upload/images/20230924/201301756r6P0RCM0H.jpg
將Hello World 改為 按鈕Tap Me,並使用注目顏色

class Homepage extends StatelessWidget (
const Homepage();
@override
Widget build(BuildContext context) (
return CupertinoPageScaffold(
child: Center(
child: CupertinoButton(
child: Text('Tap Me!'),
color: CupertinoColors.activeOrange,
onPressed: (){},
), // CupertinoButton
), // Center
); // CupertinopageScaffold

https://ithelp.ithome.com.tw/upload/images/20230924/20130175rS0PYWm6UF.jpg

編寫onPressed處理程序,並彈出Cupertino警告對話框
https://ithelp.ithome.com.tw/upload/images/20230924/20130175dqC1S5LXRR.jpg

onPressed: () {
    showDesertAlertDialog(context);
void showDesertAlertoialog(BuildContextcontext){
    showCupertinoDialog( 
        context: context,
        builder: (BuildContext context) = CupertinoAlertialog
            title: const Text ('Like Desserts?'), 
            actions: [
                CupertinoDialogAction(
                  child: const Text ('Nope"),
                  isDestructiveAction: true,
                  onPressed: () {
                    Navigator.pop(context):
                  },
                ),
                CupertinoDialogAction(
                   child: const Text ('Absolutely!'),
                   isDefauttAction: true,
                   onPressed: () {
                     Navigator. pop(context);
                     },
                    ),
                   ],
                  ),
               );
              }
            }

三個文字框(Midnight , Viridian , Cerulean)
https://ithelp.ithome.com.tw/upload/images/20230924/20130175q7CzHve6of.jpg

class HomePage extends Statelesswidget {
const HomePage ();

final Map<int, Widget> children = const <int, Widget>{
0: Text('Midnight'),
1: Text('viridian'),
2: Text ('Cerulean'), 
};

@override
Widget build(Buildcontext context) {
    return CupertinoPageScaffold(
       child: Center( 
         child: SizedBox(
           width: 375,
           child: CupertinoSegmentedControl<int>( 
             children: children,
             groupValue: 0,
             onValueChanged: (int newvalue) {},
            ).// CupertinoSwitch
          ).// Center
        ).
       );// CupertinoPageScaffold
      }
     }

上一篇
Day8-學習[Building for iOS with Flutter]得出目標應用程式
下一篇
Day10-學習[Building for iOS with Flutter]得出小部件
系列文
基礎學習Flutter30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言