화면 사이즈 구하기

 

MediaQuery.of(context).size
MediaQuery.of(context).size.height
MediaQuery.of(context).size.width

 

 

<샘플예제>

  popupAddItem() {
    showDialog(
      context: context,
      builder: (context) {
        return Dialog(
          shape:
              RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
          elevation: 16,
          child: Container(
            height: MediaQuery.of(context).size.height * 0.8,
            width: MediaQuery.of(context).size.width * 1.2,
            child: ListView(
              children: <Widget>[
                SizedBox(height: 20),
                Center(
                  child: Text(
                    "종목등록",
                    style: TextStyle(
                        fontSize: 24,
                        color: Colors.blue,
                        fontWeight: FontWeight.bold),
                  ),
                ),
                TextField(
                  controller: _textController,
                  onSubmitted: _handleSubmitted,
                  decoration: new InputDecoration(
                      hintText: "종목코드 / 종목이름으로 검색하세요.",
                      border: new UnderlineInputBorder(
                          borderSide: new BorderSide(color: Colors.red))),
                ),
                Container(
                  margin: const EdgeInsets.symmetric(horizontal: 4.0),
                  child: IconButton(
                      icon: Icon(Icons.search),
                      onPressed: () => _handleSubmitted(_textController.text)),
                ),
                _buildListItem(),
                SizedBox(height: 20),
                RaisedButton(child: Text("등록"), onPressed: (){},),
              ],
            ),
          ),
        );
      },
    );
  }

 

+ Recent posts