첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

728x90
반응형
728x170

test_app.zip
0.33MB

▶ main.dart

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

void main() {
  runApp(TestApplication());
}

class TestApplication extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Test Application',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MainPage(),
    );
  }
}

class MainPage extends StatefulWidget {
  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  final _itemList = List.generate(10, (i) => i);
  int _result = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CupertinoNavigationBar(
        middle: Text('Test Application'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CupertinoButton(
              borderRadius: BorderRadius.circular(16.0),
              color: Colors.orange,
              child: Text('RUN'),
              onPressed: () async {
                await showCupertinoModalPopup(
                  context: context,
                  builder: (context) => Container(
                    height: 200.0,
                    child: CupertinoPicker(
                      children: _itemList.map((e) => Text('항목 $e')).toList(),
                      itemExtent: 50.0,
                      scrollController: FixedExtentScrollController(initialItem: _result),
                      onSelectedItemChanged: (int index) {
                        setState(() {
                          _result = _itemList[index];
                        });
                      },
                    )
                  ),
                );
              },
            ),
            Text(
              '결과 : $_result',
            ),
          ],
        ),
      ),
    );
  }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요